Vlad Lazarenko

... making all this up as I go along

Predefined Macros

Every C and C++ compiler has several object-like macros that are implicitly defined and can be used without supplying their definitions on the command line or through including header files. Such macros are called “predefined” and can help figure out for what architecture you compile for, on what platform, if the source code being compiled is C or C++, and even tell the language standard of the code being used.

All predefined macros are described in GCC online documentation. However, not all of them are guaranteed to be defined. Sometimes it is helpful to see a list of macros defined by the compiler with their values, if any. To do that, run a preprocessor with zero input, using the following command:

cpp -dM </dev/null

This will produce the output like this:

#define __unix__ 1
#define __x86_64 1
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0
#define __GNUC_PATCHLEVEL__ 3

From the above output we can tell that code is being compiled for x86_64 architecture. The output may change depending on the platform and/or compiler settings.