Warning

I am not an adequate coder of C or C++, any information or thoughts provided here could have flaws. Moreover, I only use GNU Compiler Collection (GCC)1, some solutions may not be applicable. Please don’t hesitate to point out my mistakes.

[1]With GCC 4.8.4 on Gentoo Linux.

There is a couple of ways to issue commands for a list of predefined macros, which

[…] fall into three classes: standard, common, and system-specific.

1   Using cpp

Basically you use the following command, similar to the suggestion in GNU C++ Library’s FAQ, which requires a dummy header file, /dev/null would do and you can skip creating an empty file.


cpp -xc -std=c99 -dM /dev/null

And you will get the list of predefined macros. -dM is the key, from cpp(1):

M
Instead of the normal output, generate a list of #define directives for all the macros defined during the execution of the preprocessor, including predefined macros. This gives you a way of finding out what is predefined in your version of the preprocessor. […]

If you use -dD instead of -dM, they are listed under <builtin>.

2   Using gcc or g++

If you want to use gcc or g++ command, just add -E option:

-E
Stop after the preprocessing stage; do not run the compiler proper.

In the case above, it becomes


gcc -E -xc -std=c99 -dM /dev/null