What predefined macro can I use to detect clang?
Found the answer using strings
+ grep
:
$ strings /usr/bin/clang | grep __ | grep -i clang
__clang__
This question has been answered for years but let me add (for future reference) how it is done in Windows:
echo | clang -dM -E -
same as for GCC:
echo | gcc -dM -E -
Please note: The last dash -
is actually important! (Otherwise you get error: no input files
for both compilers)
To get a list of all the predefined macros that the compiler uses, use this:
clang -dM -E -x c /dev/null
You can do the same for gcc.