Detecting compiler versions during compile time Detecting compiler versions during compile time xcode xcode

Detecting compiler versions during compile time


As someone who has ported more than his fair share of 'C' around, I can see were you are coming from, so here is some to get us started:

For IBM CL/C++ compiler product:

__xlc__  - Format is V.R.M.F eg: "9.0.0.0"__IBMCPP__ Format is an integer as VRM eg: V9.0 is 900__IBMC__ - Format is an integer as VRM,            which indicates the level of compiler as VRM as:< 200 is C Set/2< 300 is C Set++otherwise is Visual Age C++ V.M.C           where V=version, M=release, M=modification and F=fix level.

For Borland C:

___BORLANDC__ ??

For GNU C:

__GNUC__ ??

For Watcon C:

__WATCOMC__


There is a table of this information here:

https://sourceforge.net/p/predef/wiki/Compilers/

Sadly, It appears that MacOS defines __clang__, __GNUCC__ and __llvm__ so this information can get a little confused.

But usually, only one set of information applies.