Printing all the pre defined gcc macros

26.10.2007 at 22:50

Another thing which is quite useful when dealing with preprocessor issues is a list of all compiler defined macros. So here you go.

gcc -dM -E - < /dev/null

Marc

Comments (4)

Thanks!

07.05.2008 by Nikolodeon

I've searching for a commandline like this! thankyou

Thanks too!

26.07.2008 by Alex Telea

This is great. I spent >5 hours trying to find out how to do that.. Alex

Alternative

01.10.2010 by Vlad Lazarenko (vlad[at]lazarenko[dot]me)

You can also do "cpp -dM </dev/null", which invokes preprocessor directly.

also source-defined ?

30.01.2019 by PypeBros (pype_1999.geo[at]yahoo[dot]com)

I was wondering whether this would also capture the #defines that occur while parsing the source code. Good news is that it does so if you pass a non-empty source file to the GCC command line. Btw, you might want to know that question 2224334 on stack overflow also has -x c++ when doing that for c++ instead of plain C.

1