macros to indicate the compiler and its version

来源:互联网 发布:系统清理软件 编辑:程序博客网 时间:2024/05/02 09:09

Most compilers defines macros to indicate the compiler and its version. These are useful to avoid bugs in certain compiler versions, or to check for the existance of certain features.

Table of Content - Compilers

Table of Content - Compilers
Borland Turbo C
Borland C++
Comeau C++
Compaq C/C++
Cray C
Cygwin
Diab C/C++
Digital Mars
DJGPP
EKOPath
EDG C++ Front End
GNU C/C++
Green Hill C/C++
HP ANSI C
HP aCC
IBM XL C/C++
IBM z/OS C/C++
IAR C/C++
Intel C/C++
KAI C++
Keil CARM
Keil C166
Keil C51
LCC
LLVM
MetaWare High C/C++
Metrowerks CodeWarrior
MinGW
MIPSpro
MPW C++
Microsoft Visual C++
Microtec C/C++
Norcroft C
Pacific C
Palm C/C++
Pelles C
Portland Group C/C++
RealView C
SAS/C
SCO OpenServer
Small Device C Compiler
Sun Studio
Systems/C and Systems/C++
TenDRA C/C++
Tiny C
Ultimate C/C++
USL C
Watcom C++

Borland Turbo C

Type Macro Format Identification __TURBOC__ . Version __TURBOC__ ?

Example

Turbo C __TURBOC__ 2.0 397 3.0 661

Official site Wikipedia

Borland C++

Type Macro Format Identification __BORLANDC__ . Version __BORLANDC__ ?

Example

Borland C++ C++ Builder __BORLANDC__ 2.0 . 0x200 3.0 . 0x400 3.1 . 0x410 4.0 . 0x452 5.0 . 0x500 5.02 1.0 0x520 . 3.0 0x530 . 4.0 0x540 5.5 5.0 0x550 5.51 . 0x551

Official site Google Directory Wikipedia

Comeau C++

Type Macro Format Description Identification __COMO__ . . Version __COMO_VERSION__ VRR V = Version
RR = Revision

Example

Comeau C++ __COMO_VERSION__ 2.3 230

Official site

Compaq C/C++

Type Macro Format Description Identification __DECC . C compiler Version __DECC_VER VVRRTPPPP VV = Version
RR = Revision
T = Type (9 = official)
PPPP = Patch Identification __DECCXX . C++ compiler Version __DECCXX_VER As __DECC_VER . Identification __VAXC . Obsolete Identification VAXC . Obsolete

Example

Compaq C/C++ __DECC_VER 6.0-001 60090001

Official site

Cray C

Type Macro Description Identification _CRAYC . Version _RELEASE Version Version _RELEASE_MINOR Revision

Official site

Cygwin

Type Macro Identification __CYGWIN__

Official site Wikipedia

Diab C/C++

Type Macro Format Description Identification __DCC__ 1 . Version __VERSION_NUMBER__ VRPP V = Version
R = Revision
PP = Patch

Example

Diab C/C++ __VERSION_NUMBER__ 4.4g 4426

Official site

Digital Mars

Type Macro Format Description Identification __DMC__ . . Identification __SC__ . Obsolete Identification __ZTC__ . Obsolete Version __DMC__ 0xVRP V = Version
R = Revision
PP = Patch

Example

Digital Mars __DMC__ 7.0 0x700 7.2 0x720 8.0 0x800

Official site

DJGPP

Type Macro Description Identification __DJGPP__ . Version __DJGPP__ Version Version __DJGPP_MINOR__ Revision Identification __GO32__ Defined by DJGPP 1.x

Example

DJGPP __DJGPP__ __DJGPP_MINOR__ 2.01 2 1

Official site Google Directory Wikipedia

EKOPath

Type Macro Description Identification __PATHCC__ . Version __PATHCC__ Version Version __PATHCC_MINOR__ Revision Version __PATHCC_PATCHLEVEL__ Patch

Example

EKOPath __PATHCC__ __PATHCC_MINOR__ __PATHCC_PATCHLEVEL__ 2.0 2 0 0

Official site

EDG C++ Front End

Type Macro Format Description Identification __EDG__ . . Version __EDG_VERSION__ VRR V = Version
RR = Revision

Example

EDG C++ __EDG_VERSION__ 2.30 230

Official site

GNU C/C++

Type Macro Description Identification __GNUC__ . Version __GNUC__ Version Version __GNUC_MINOR__ Revision Version __GNUC_PATCHLEVEL__ Patch (introduced in version 3.0)

Example

GNU C/C++ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ 2.7.x 2 7 . 3.0.2 3 0 2

Alternative Version

If you prefer a single version macro, you can define the following yourself.

#if defined(__GNUC__)# if defined(__GNUC_PATCHLEVEL__)#  define __GNUC_VERSION__ (__GNUC__ * 10000 /                            + __GNUC_MINOR__ * 100 /                            + __GNUC_PATCHLEVEL__)# else#  define __GNUC_VERSION__ (__GNUC__ * 10000 /                            + __GNUC_MINOR__ * 100)# endif#endif

The format of this new macro is:

Type Macro Format Description Version __GNUC_VERSION__ VVRRPP VV = Version
RR = Revision
PP = Patch

Example of Alternative Version

GNU C/C++ __GNUC_VERSION__ 2.7.x 20700 3.0.2 30002

Official site Google Directory Wikipedia

Green Hill C/C++

Type Macro Format Description Identification __ghs__ . . Version __GHS_VERSION_NUMBER__ VRP V = Version
R = Revision
P = Patch Version __GHS_REVISION_DATE__ Epoch time .

Example

Green Hill C/C++ __GHS_VERSION_NUMBER__ 4.2.1 421

Official site Wikipedia

HP ANSI C

Type Macro Identification __HP_cc

Official site

HP aCC

Type Macro Format Description Identification __HP_aCC . . Version __HP_aCC 1 From version A.01.15 (and A.03.13) Version __HP_aCC VVRRPP VV = Version
RR = Revision
PP = Patch

From version A.01.21 (and A.03.25)

HP aCC __HP_aCC A.01.21 012100

Official site

IBM XL C/C++

Type Macro Format Description Identification __xlC__ . . Version __xlC__ 0xVVRR VV = Version
RR = Revision Identification __IBMC__ . From ? Identification __IBMCPP__ . From ? Version __IBMC__
__IBMCPP__ VRP V = Version
R = Revision
P = Patch

Please note that the z/OS C/C++ compiler also defines __IBMC__ and __IBMCPP__ macros, but with a different syntax. See the entry on the z/OS C/C++ compiler below for further information.

Example

IBM XL C/C++ __xlC__ __IBMC__ 3.1 0x0301 . 4.5 0x0405 450 5.0 0x0500 500

Official site Wikipedia

IBM z/OS C/C++

This is the XL C/C++ compiler for mainframes (e.g. z/OS). The entry on XL C/C++ has been split into two for clarity.

Type Macro Format Description Identification __IBMC__ . . Identification __IBMCPP__ . . Version __IBMC__
__IBMCPP__ NVRRM N = Product (0 = C/370, 1 = MVS, 2 = OS/390, 4 = z/OS)
V = Version
RR = Revision
P = Patch

Defined for z/OS XL C/C++ Version __COMPILER_VER__ 0xNVRRPPPP N = Product (see above)
V = Version
RR = Revision
PPPP = Patch

Defined for z/OS XL C/C++

Please note that XL C/C++ also defines __IBMC__ and __IBMCPP__ macros, but with a different syntax. You can use __xlC__ (only defined for XL C/C++) or __COMPILER_VER__ (only defined for z/OS C/C++) to distinguish between the two.

#if defined(__IBMC__) || defined(__IBMCPP__)# if defined(__COMPILER_VER__)/* z/OS C/C++ so __IBMC__ is defined as NVRRM */# else/* XL C/C++ so __IBMC__ is defined as VRP */# endif#endif

Example

IBM z/OS XL C/C++ __IBMC__ __COMPILER_VER__ 1.7 41070 0x41070000

Official site Wikipedia

IAR C/C++

Type Macro Format Description Identification __IAR_SYSTEMS_ICC__ . . Version __VER__ VRR V = Version
RR = Revision

Example

IAR C/C++ __VER__ 3.34 334

Official site

Intel C/C++

Type Macro Format Description Identification __INTEL_COMPILER . . Identification __ICC . Obsolete Identification __ECC . Obsolete Identification __ICL . . Version __INTEL_COMPILER VRP V = Version
R = Revision
P = Patch Version __INTEL_COMPILER_BUILD_DATE YYYYMMDD YYYY = Year
MM = Month
DD = Day

Example

Intel C/C++ __INTEL_COMPILER __INTEL_COMPILER_BUILD_DATE 5.0 500 . 6.0 600 . 8.0 800 . 9.0 900 20060222

Official site

KAI C++

Type Macro Format Description Identification __KCC . . Version __KCC_VERSION 0xVRPP V = Version
R = Revision
PP = Patch (a = 01, b = 02, ...)

Example

KAI C++ __KCC_VERSION 4.0d 4004

Official site

Keil CARM

Type Macro Format Description Identification __CA__ . . Identification __KEIL__ . . Version __CA__ VRR V = Version
R = Revision

Example

Keil CARM __CA__ 1.01 101

Official site

Keil C166

Type Macro Format Description Identification __C166__ . . Version __C166__ VRR V = Version
R = Revision

Example

Keil C166 __C166__ 5.01 501

Official site

Keil C51

Type Macro Format Description Identification __C51__ . . Identification __CX51__ . . Version __C51__ VRR V = Version
R = Revision

Example

Keil C51 __C51__ 7.01 701

Official site

LCC

Type Macro Identification __LCC__

Official site Wikipedia

LLVM

Type Macro Identification __llvm__

Official site Wikipedia

MetaWare High C/C++

Type Macro Identification __HIGHC__

Official site

Metrowerks CodeWarrior

Type Macro Format Description Identification __MWERKS__ . . Version __MWERKS__ 1 Until CodeWarrior 7 Version __MWERKS__ 0xVRPP V = Version
R = Revision
PP = Patch

From CodeWarrior 7

Example

Metrowerks C/C++ __MWERKS__ 2.0 0x2000 2.2 0x2200

Official site Wikipedia

MinGW

Type Macro Description Identification __MINGW32__ . Version __MINGW32_MAJOR_VERSION Version Version __MINGW32_MINOR_VERSION Revision

Example

MinGW __MINGW32_MAJOR_VERSION __MINGW32_MINOR_VERSION 2.4 2 4

Official site Wikipedia

MIPSpro

Type Macro Format Description Identification __sgi . . Identification sgi . . Version _COMPILER_VERSION VRP V = Version
R = Revision
P = Patch

Until ? Version _SGI_COMPILER_VERSION VRP V = Version
R = Revision
P = Patch

From ?

Example

MIPSpro _COMPILER_VERSION _SGI_COMPILER_VERSION 6.0.2 602 . 7.2.1 721 . 7.4.4 . 744

Official site

MPW C++

Type Macro Format Description Identification __MRC__ . . Identification MPW_C . . Identification MPW_CPLUS . . Version __MRC__ 0xVVRR VV = Version
RR = Revision

Example

MPW C++ __MRC__ 5.0 0x500

Official site

Microsoft Visual C++

Type Macro Format Description Identification _MSC_VER . . Version _MSC_VER VVRR VV = Version
RR = Revision Version _MSC_FULL_VER VVRRPPPP VV = Version
RR = Revision
PPPP = Patch

From ? Version _MSC_FULL_VER VVRRPPPPP VV = Version
RR = Revision
PPPPP = Patch

From ?

Please note that _MSC_FULL_VER is not officially documented by the vendor.

Example

Visual C++ _MSC_VER _MSC_FULL_VER 1.0 800 . 3.0 900 . 4.0 1000 . 4.2 1020 . 5.0 1100 . 6.0 1200 . 6.0 SP6 1200 12008804 7.0 1300 13009466 7.1 (2003) 1310 13103077 8.0 (2005) 1400 140050727

Official site Google Directory Wikipedia

Microtec C/C++

Type Macro Identification _MRI

Official site

Norcroft C

Type Macro Format Description Identification __CC_NORCROFT . . Version __ARMCC_VERSION V.R V = Version
R = Revision

Please note that __ARMCC_VERSION is assigned a floating-point number, so it cannot be used by the preprocessor to compare versions.

Example

Norcroft C __ARMCC_VERSION 4.69 4.69 4.90 4.90

Pacific C

Type Macro Identification __PACIFIC__

Official site

Palm C/C++

Type Macro Format Description Identification _PACC_VER . . Version _PACC_VER 0xVRRPPBBB V = Version
RR = Revision
PP = Patch
BBB = Build

Example

Palm C/C++ _PACC_VER 1.0.0.13 0x1000000D

Official site Google Directory

Pelles C

Type Macro Format Description Identification __POCC__ . . Version __POCC__ VRR V = Version
RR = Revision

Example

Pelles C __POCC__ 3.00 300

Official site

Portland Group C/C++

Type Macro Identification __PGI

Official site

RealView C

Type Macro Format Description Identification __CC_ARM . . Version __ARMCC_VERSION VRPBBB V = Version
R = Revision
P = Patch
BBB = Build

Please note that the __ARMCC_VERSION macro is also used as version indicator for Norcroft C, but that the format is different.

Example

Realview C __ARMCC_VERSION 3.0 300503

Official site

SAS/C

Type Macro Format Description Identification SASC . . Identification __SASC . . Identification __SASC__ . . Version __VERSION__ . Until ? Version __REVISION__ . Until ? Version __SASC__ VRR V = Version
RR = Revision

From ?

Example

SAS/C __SASC__ __VERSION__ __REVISION__ 5.10 . 5 10 6.50 650 . .

Official site

SCO OpenServer

Type Macro Identification _SCO_DS

Official site

Small Device C Compiler

Type Macro Format Description Identification SDCC . . Version SDCC VRP V = Version
R = Revision
P = Patch

Example

SDCC Version SDCC Macro 2.5.6 256

Official site Google Directory Wikipedia

Sun Studio

Type Macro Format Description Identification __SUNPRO_C . C compiler Version __SUNPRO_C 0xVRP V = Version
R = Revision
P = Patch Identification __SUNPRO_CC . C++ compiler Version __SUNPRO_CC As __SUNPRO_C .

Example

Sun Studio __SUNPRO_C 4.2 0x420 5.0 0x500

Official site

Systems/C and Systems/C++

Type Macro Format Description Identification __SYSC__ . C compiler Version __SYSC_VER__ VRRPP V = Version
RR = Revision
PP = Patch

Example

Systems/C __SYSC_VER__ 1.80.32 18032

Official site

TenDRA C/C++

Type Macro Identification __TenDRA__

Official site Wikipedia

Tiny C

Type Macro Identification __TINYC__

Official site

Ultimate C/C++

Type Macro Description Identification _UCC . Version _MAJOR_REV = V
_MINOR_REV = R V = Version
R = Revision

Example

Ultimate C/C++ _MAJOR_REV _MINOR_REV 2.1 2 1

USL C

Type Macro Format Description Identification __USLC__ . . Version __SCO_VERSION 0xVRRYYYYMM V = Version
RR = Revision
YYYY = Year
MM = Month

Example

USL C __SCO_VERSION 3.2 302199801

Official site

Watcom C++

Type Macro Format Description Identification __WATCOMC__ . . Version __WATCOMC__ VVRR VV = Version
RR = Revision

Example

Watcom C++ __WATCOMC__ 10.5 1050 11.0 1100

Official site Wikipedia  

原创粉丝点击