Possible Duplicate:
How can I make the preprocessor insert linebreaks into the macro expansion result?
#define IDENTIFIER { /*new line here*/\
my_multiline(); /*new line here*/\
macro(); /*new line here*/\
} /*new line here*/
Can I force the C pre-processor to generate a new line in it's expansion? I don't believe there's a standard way to do this but I wouldn't mind platform specific hacks for Visual C++ (2008) and gcc.
I'm not interested in doing this through m4 or a separate pre-processor.
Why I'm asking this:
It's more or less just curiosity. Since it's a hack I'm not going to try this in production but I'd like to know if I'm able to do this anyway. A few days ago I stumbled into this question:
Can you turn off (specific) compiler warnings for any header included from a specific location?
This is a question that I'd like a solution myself. I thought about creating a macro for including a header, but with correct pragmas to disable a warning before the including, include the header I'd like to turn warnings off, enabling the warning after the include.
Of course, I could create a script to generate mock includes with the pragma for the warning and the include.
My first problem was that since #include
is a pre processor directive a macro would be somewhat useless to generate it. But then I found this answer:
Is there a way to do a #define inside of another #define?
With this I believe I can generate the special include macro if I'm able to force the compiler to generate newlines in it's expansion.
I'm at home right now but I'll post my code tomorrow when I'm at work.