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
Example
Turbo C __TURBOC__ 2.0 397 3.0 661
Borland C++
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
Comeau C++
RR = Revision
Example
Comeau C++ __COMO_VERSION__ 2.3 230
Compaq C/C++
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
Cray C
Cygwin
Diab C/C++
R = Revision
PP = Patch
Example
Diab C/C++ __VERSION_NUMBER__ 4.4g 4426
Digital Mars
R = Revision
PP = Patch
Example
Digital Mars __DMC__ 7.0 0x700 7.2 0x720 8.0 0x800
DJGPP
Example
DJGPP __DJGPP__ __DJGPP_MINOR__ 2.01 2 1
EKOPath
Example
EKOPath __PATHCC__ __PATHCC_MINOR__ __PATHCC_PATCHLEVEL__ 2.0 2 0 0
EDG C++ Front End
RR = Revision
Example
EDG C++ __EDG_VERSION__ 2.30 230
GNU C/C++
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:
RR = Revision
PP = Patch
Example of Alternative Version
GNU C/C++ __GNUC_VERSION__ 2.7.x 20700 3.0.2 30002
Green Hill C/C++
R = Revision
P = Patch Version __GHS_REVISION_DATE__ Epoch time .
Example
Green Hill C/C++ __GHS_VERSION_NUMBER__ 4.2.1 421
HP ANSI C
HP aCC
RR = Revision
PP = Patch
From version A.01.21 (and A.03.25)
HP aCC __HP_aCC A.01.21 012100
IBM XL C/C++
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
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.
__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
IAR C/C++
RR = Revision
Example
IAR C/C++ __VER__ 3.34 334
Intel C/C++
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
KAI C++
R = Revision
PP = Patch (a = 01, b = 02, ...)
Example
KAI C++ __KCC_VERSION 4.0d 4004
Keil CARM
R = Revision
Example
Keil CARM __CA__ 1.01 101
Keil C166
R = Revision
Example
Keil C166 __C166__ 5.01 501
Keil C51
R = Revision
Example
Keil C51 __C51__ 7.01 701
LCC
LLVM
MetaWare High C/C++
Metrowerks CodeWarrior
R = Revision
PP = Patch
From CodeWarrior 7
Example
Metrowerks C/C++ __MWERKS__ 2.0 0x2000 2.2 0x2200
MinGW
Example
MinGW __MINGW32_MAJOR_VERSION __MINGW32_MINOR_VERSION 2.4 2 4
MIPSpro
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
MPW C++
RR = Revision
Example
MPW C++ __MRC__ 5.0 0x500
Microsoft Visual C++
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
Microtec C/C++
Norcroft C
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
Palm C/C++
RR = Revision
PP = Patch
BBB = Build
Example
Palm C/C++ _PACC_VER 1.0.0.13 0x1000000D
Pelles C
RR = Revision
Example
Pelles C __POCC__ 3.00 300
Portland Group C/C++
RealView C
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
SAS/C
RR = Revision
From ?
Example
SAS/C __SASC__ __VERSION__ __REVISION__ 5.10 . 5 10 6.50 650 . .
SCO OpenServer
Small Device C Compiler
R = Revision
P = Patch
Example
SDCC Version SDCC Macro 2.5.6 256
Sun Studio
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
Systems/C and Systems/C++
RR = Revision
PP = Patch
Example
Systems/C __SYSC_VER__ 1.80.32 18032
TenDRA C/C++
Tiny C
Ultimate C/C++
_MINOR_REV = R V = Version
R = Revision
Example
Ultimate C/C++ _MAJOR_REV _MINOR_REV 2.1 2 1
USL C
RR = Revision
YYYY = Year
MM = Month
Example
USL C __SCO_VERSION 3.2 302199801
Watcom C++
RR = Revision
Example
Watcom C++ __WATCOMC__ 10.5 1050 11.0 1100
- macros to indicate the compiler and its version
- C/C++ tip: How to detect the operating system type using compiler predefined macros
- some macros and extension C language of IAR C compiler
- some macros and extension C language of IAR C compiler
- How to get Version of the application and API version
- Use string::npos to indicate ``the rest of the string;''
- wxWidgets: How to initialize wxApp without using macros and without entering the main loop
- On the Way to the Web: The Secret History of the Internet and Its Founders
- SVN:is not under version control and is not part of the commit,yet its child
- svn:is not under version control and is not part of the commit, yet its child '
- What are the __init* and __exit* macros ?
- Pre-defined Compiler Macros
- How to check the java compiler version from a java class file?
- svn:is not under version control and is not part of the commit, yet its child解决办法
- ADF: The best way to indicate for records in a table the existence of details
- 2.4. Hello World (part 3): The __init and __exit Macros
- How to set up Eclipse with the gcc C++ compiler and GoogleTest on Windows7, from scratch
- Introduction to AT commands and its uses
- 工作效率和薪水加倍的7个秘诀
- 出栈序列与Catalan 0-1序列
- .NET2.0TreeView使用脚本模拟选中结点
- 管理的白菜汤
- Asp.net资源
- macros to indicate the compiler and its version
- PHPLAMP站 PHP学习平台 上传成功
- 开始写博客了,作为自己学习的见证吧!
- 搭建Eclipse+MyEclipse开发环境
- Calculate years, months, days & calender days between 2 given dates
- 在你40岁以前需要做的事
- IT项目管理,技术重要还是管理重要?
- JavaScript学习笔记(1)
- 走职场必看的12寓言故事