25 April 2008

Get the list of gcc defined macro after preprocessing

It various situation, it is very useful to get the list of all defined maco after gcc preprocessing.
Particularly when porting C/C++ source code to another OS/Architecture to know what macro to use to identify it.

A simple way is to use gcc with the following options:
-E to end after preprocessing step,
-dM to print all defined macros.

For instance to known the "default" macros, use those options with a simple source code file "test.c" defining a main function:
gcc -E -dM test.c

No comments:

Post a Comment

Thank you for your visit, let's share your point of view: