Is there a good general method for debugging C++ macros?

c++, debugging, gcc, macros

Solution

gcc -E will output the preprocessed source to stdout.

Problem

In general, I occasionally have a chain of nested macros with a few preprocessor conditional elements in their definitions. These can be painful to debug since it's hard to directly see the actual code being executed. A while ago I vaguely remember finding a compiler (gcc) flag to expand them, but I had trouble getting this to work in practice.

Original source