With C/C++ macros it's quite easy to generated long constructs automatically. For example, if I want a huge set of methods to not ever throw exceptions (a must for COM-exposed methods) I can do something like this:
#define BEGIN_COM_METHOD\
try{
#define END_COM_METHOD\
return S_OK;\
} catch( exception& ) {\
// set IErrorInfo here\
return E_FAIL;\
}
to make such macros manageable one can use "\" character to make the macro definition multiline and more readable.
The problem is sometimes code with such constructs will not compile - something will not expand as expected and invalid code will be present to the compiler. Compiler usually have "generate preprocessed file" option to show the developer the preprocessing result. But in the preprocessed file the macro is expanded into one line and the result is barely readable.
Is it possible to make the preprocessor to keep the linebreaks present in the macro definition?