How to list compiler predefined macros
- Excerpted from Nadeau article
All C/C++ compilers predefine macros indicating the target processor, operating system, language features, compiler name and version, and more. Cross-platform code can use #if/#endif
to wrap OS-specific #includes (such as
This article surveys common desktop and server application compilers and shows how to list their predefined macros.
Compiler | C macros | C++ macros |
---|---|---|
Clang/LLVM | clang -dM -E -x c /dev/null | clang++ -dM -E -x c++ /dev/null |
GNU GCC/G++ | gcc -dM -E -x c /dev/null | g++ -dM -E -x c++ /dev/null |
Hewlett-Packard C/aC++ | cc -dM -E -x c /dev/null | aCC -dM -E -x c++ /dev/null |
IBM XL C/C++ | xlc -qshowmacros -E /dev/null | xlc++ -qshowmacros -E /dev/null |
Intel ICC/ICPC | icc -dM -E -x c /dev/null | icpc -dM -E -x c++ /dev/null |
Microsoft Visual Studio | (none) | (none) |
Oracle Solaris Studio | cc -xdumpmacros -E /dev/null | CC -xdumpmacros -E /dev/null |
Portland Group PGCC/PGCPP | pgcc -dM -E | (none) |