How to check what is defined in gcc

2012-06-14 at 22:31:02 | categories: tips

What defines are available to your program compiled with GCC

Lately I spent some time trying to figure out why the hell my old programs does not work correctly. It turned out it did not swap some bytes because #if defined(linux) && defined(i386) returned false (since I have 64bit machine).

Then I needed to find out what should I use for 64bit - it is __x86_64.

However what is really cool is how to figure out what defines you have available when you use gcc: cpp -dM /dev/null check it out! There are many interesting things you can see there.