C ++ Macro Expander

Sometimes I come across quite complex macros, and I would like to see what they will expand to the given parameters (there are also string concatenations). Is there any program that extends macros?

I know the -E compiler flag, but what about one file (or preferably one macro?)

+4
source share
4 answers

Eclipse will expand the macros if you click on them. For macros that include other macros, Eclipse can even create macros one step at a time.

(You can use Eclipse to do this, even if you usually use a different IDE.)

+4
source

Several variants:
In GCC:

gcc -E filename.c

Using computer precompiler:

 cpp filename.c 

In Visual Studio:
Right-click the file in Solution Explorer, go to Properties. Under "Configuration Properties" -> C / C ++ -> Preprocessor and "Create a Pre-Processed File"

+3
source

The C and C ++ preprocessor is called cpp on most systems - you can use it directly:

 cpp somefile.c 

will preprocess somefile.c, expanding macros and writing the results to standard output. If you are using the Microsoft compiler:

 cl -E somefile.c 

will do the same if you have a compiler on your PATH.

+2
source

The Netbeans IDE allows you to see that the macro expands while holding Ctrl + Alt and the macro freezes / clicks.

+1
source

All Articles