Is there a way for gcc/g++ to dump its preprocessor defines from the command line?
I mean things like __GNUC__
, __STDC__
, and so on.
Late answer - I found the other answers useful - and wanted to add a bit extra.
How do I dump preprocessor macros coming from a particular header file?
echo "#include " | gcc -E -dM -
or (thanks to @mymedia for the suggestion):
gcc -E -dM -include sys/socket.h - < /dev/null
In particular, I wanted to see what SOMAXCONN was defined to on my system. I know I could just open up the standard header file, but sometimes I have to search around a bit to find the header file locations. Instead I can just use this one-liner:
$ gcc -E -dM -include sys/socket.h - < /dev/null | grep SOMAXCONN
#define SOMAXCONN 128
$