Pre-defined C/C++ Compiler Macros
https://sourceforge.net/p/predef/wiki/Home/
The macros are found here:
General guidelines are found here:
Introduction
C and C++ compilers automatically define certain macros that can be used to check for compiler or operating system features. This is useful when writing portable software.
These pages lists various pre-defined compiler macros that can be used to identify standards, compilers, operating systems, hardware architectures, and even basic run-time libraries at compile-time.
For example, if we want to use a generic or opaque pointer type, we use void pointers. However, ancient K&R compilers (from the time before the first ANSI C standard) do not support void pointers. Instead we can define our own type:
#if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_EXTENSIONS)
typedef void * t_pointer;
#else
typedef char * t_pointer;
#endif
Another example, Microsoft Visual C++ version 4.2 added a pragma to reduce compilation times by only including a file once (if _MSC_VER is not defined then it will evaluate to 0 (zero) — however, some compilers may complain about an undefined macro)
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
The macros contained in these pages have been obtained through vendor documentation, the defines script, contributors, and third-party source code. No guarantee about the correctness of the macros is given.
An often-used alternative is Autoconf, which is a more powerful tool to examine various types of features, including compilation options. However, Autoconf is fairly Unix-centric, and requires a Unix layer on other platforms (e.g. Cygwin on Windows). Other alternatives are Buildtool, CMake, SCons, PMK, Jam, Ant, and Bakefile.
Contributors
Bjorn Reese, Daniel Stenberg, Greg Roelofs, Steven G. Johnson, Wlodzimierz ABX Skiba, Marc Finet, Philip Newton, Mitchell Charity, Christian Klutz, Seo Sanghyeon, Chris Adami, Geoff Clare, Dan Fandrich, Mike Gorchak, Yuri D'Elia, Gynvael Coldwind, Alain Tauch, Vadim Zeitlin, Steve White, Thomas David Rivers, Tom Honermann, Martin Mitas, Dinesh Chhadwa, Erik Faye-Lund, Leo Davis, Paul Hsieh, Roland Schwarz, Darko Kolakovic, Andy Buonviri, Ming Kin Lai, Kent Johnson, Helmut Bauer, Oliver Schneider, Ron Pimblett, Jose Luis Rodriguez Garcia, Jeroen Ruigrok van der Werven, Uffe Jakobsen, Bryan Ashby, Bruno Haible, Artur Bac, Terry Schwarz, Leo Davis, Markus Duft, William Dang, Paul Green, Ruben Van Boxem, Pau Garcia i Quiles, Mikulas Patocka, Leo Davis, Mark Ferry, Holger Machens, Simon Watts, Paul Hargrove, Hans-Christoph Steiner, Gerald Combs, Denys Bulant, Massimo Morara, Jeremy Bennett, Guillem Jover, Riku Voipio, Jacques Pelletier, Mark Jarvin, Georg Sauthoff, Scot Jenkins, Grzegorz Brzęczyszczykiewicz, John Dallman, Gianmichele Toglia, Robbie Groenewoudt, Andreas Mohr, Алексей Пюрецкий, Sverre Hvammen Johansen, Stefan Tauner, Daniel Garcia, Ozkan Sezer, Dean Saridakis, Frank Long, Kevin Adler.
Language Standards
Language standards requires the existence of pre-defined macros.
Name |
Macro |
Standard |
C89 |
|
ANSI X3.159-1989 |
C90 |
|
ISO/IEC 9899:1990 |
C94 |
|
ISO/IEC 9899-1:1994 |
|
ISO/IEC 9899:1999 |
|
|
ISO/IEC 9899:2011 |
|
|
ISO/IEC 14882:1998 |
|
|
ISO/IEC 14882:2011 |
|
|
ISO/IEC 14882:2014 |
|
|
ECMA-372 |
|
ISO/IEC JTC1/SC22 WG14/N854 |
||
|
Embedded C++ |
Example: C Standards
#if defined(__STDC__)
# define PREDEF_STANDARD_C_1989
# if defined(__STDC_VERSION__)
# if (__STDC_VERSION__ >= 199409L)
# define PREDEF_STANDARD_C_1994
# endif
# if (__STDC_VERSION__ >= 199901L)
# define PREDEF_STANDARD_C_1999
# endif
# endif
#endif
Notice that not all compliant compilers provides the correct pre-defined macros. For example, Microsoft Visual C++ does not define __STDC__
, or Sun Workshop 4.2 supports C94 without setting __STDC_VERSION__
to the proper value. Extra checks for such compilers must be added.
Notice that some compilers, such as the HP aC++, use the value 199707L to indicate the C++98 standard. This value was used in an earlier proposal of the C++98 standard.
Example: Pre-C89
In continuation of the above example, pre-C89 compilers do not recognize certain keywords. Let the preprocessor remove those keywords for those compilers.
#if !defined(PREDEF_STANDARD_C_1989) && !defined(__cplusplus)
# define const
# define volatile
#endif
Unix Standards
There are several related Unix standards, such as POSIX, X/Open, and LSB.
Unix standards require the existence macros in the <unistd.h>
header file.
Name |
Macro |
Standard |
POSIX.1-1988 |
|
|
POSIX.1-1990 |
|
ISO/IEC 9945-1:1990 |
POSIX.2 |
|
ISO/IEC 9945-2:1993 |
POSIX.1b-1993 |
|
IEEE 1003.1b-1993 |
POSIX.1-1996 |
|
IEEE 1003.1-1996 |
POSIX.1-2001 |
|
IEEE 1003.1-2001 |
|
IEEE 1003.1-2008 |
|
XPG3 |
|
X/Open Portability Guide 3 (1989) |
XPG4 |
|
X/Open Portability Guide 4 (1992) |
SUS |
|
X/Open Single UNIX Specification (UNIX95) |
|
X/Open Single UNIX Specification, Version 2 (UNIX98) |
|
|
Open Group Single UNIX Specification, Version 3 (UNIX03) |
|
|
Open Group Single UNIX Specification, Version 4 |
|
LSB |
|
Linux Standards Base |
Example: Unix Standards
The following examples assumes the definition of these macros.
#if defined(unix) || defined(__unix__) || defined(__unix)
# define PREDEF_PLATFORM_UNIX
#endif
#if defined(PREDEF_PLATFORM_UNIX)
# include <unistd.h>
# if defined(_XOPEN_VERSION)
# if (_XOPEN_VERSION >= 3)
# define PREDEF_STANDARD_XOPEN_1989
# endif
# if (_XOPEN_VERSION >= 4)
# define PREDEF_STANDARD_XOPEN_1992
# endif
# if (_XOPEN_VERSION >= 4) && defined(_XOPEN_UNIX)
# define PREDEF_STANDARD_XOPEN_1995
# endif
# if (_XOPEN_VERSION >= 500)
# define PREDEF_STANDARD_XOPEN_1998
# endif
# if (_XOPEN_VERSION >= 600)
# define PREDEF_STANDARD_XOPEN_2003
# endif
# if (_XOPEN_VERSION >= 700)
# define PREDEF_STANDARD_XOPEN_2008
# endif
# endif
#endif
Notice that not all compliant compilers provides the correct pre-defined macros. For example, IBM xlC supports Unix without setting any of the __unix__
macros. Extra checks for such compilers must be added.
Compilers
ACC
Type |
Macro |
Identification |
|
Altium MicroBlaze C
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRRR |
V=Version |
Version |
|
P |
P=Patch |
Version |
|
VRRRPPP |
Build number |
Example
Altium MicroBlaze C |
|
|
|
1.0r2 |
1000 |
2 |
|
1.22.2 |
1022001 |
Altium C-to-Hardware
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRRR |
V=Version |
Version |
|
P |
P=Patch |
Version |
|
VRRRPPP |
Build number |
Example
Altium C-to-Hardware |
|
|
|
2.1r1 |
2001 |
1 |
|
1.22.2 |
1022001 |
Amsterdam Compiler Kit
Type |
Macro |
Identification |
|
ARM Compiler
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRPBBB |
V = Version |
Notice that the __ARMCC_VERSION
macro is also used as version indicator for Norcroft C, but that the format is different.
Example
Realview C |
|
3.0 |
300503 |
Aztec C
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRR |
V = Version |
Example
Aztec C |
|
5.20 |
520 |
Borland C++
Type |
Macro |
Format |
Identification |
|
|
Version |
|
? |
Identification |
|
|
Version |
|
From C++ Builder 2006 |
Example
Borland C++ |
C++ Builder |
|
|
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 |
||
5.6.4 |
0x562 |
||
2006 |
0x570 |
0x570 |
|
2007 |
0x590 |
0x590 |
|
2009 |
0x613 |
0x613 |
|
2010 |
0x621 |
0x621 |
|
XE |
0x630 |
0x630 |
|
XE2 |
0x640 |
0x640 |
|
XE3 |
0x650 |
0x650 |
|
XE4 |
0x660 |
0x660 |
CC65
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
0xVRP |
V = Version |
Example
Version |
|
2.10.1 |
0x2A1 |
Clang
Type |
Macro |
Format |
Identification |
|
|
Version |
|
Version |
Version |
|
Revision |
Version |
|
Patch |
Notice that clang also defines the GNU C version macros, but you should use the clang feature checking macros to detect the availability of various features.
The values of the __clang_major__
, __clang_minor__
, and __clang_patchlevel__
macros are not consistent across distributions of the Clang compiler. For example, the Clang 3.1 distribution available at http://clang.llvm.org defines __clang_major__
and __clang_minor__
as 3
and 1
respectively. The version of Clang distributed with Apple XCode 4.4 is branded as "Apple Clang 4.0" and derives from the open source Clang 3.1 distribution, but defines these macros with the values 4
and 0
respectively. Apple's Clang distribution can be identified by the presence of the __apple_build_version__
macro.
Comeau C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRR |
V = Version |
Example
Comeau C++ |
|
2.3 |
230 |
Compaq C/C++
Type |
Macro |
Format |
Description |
Identification |
|
C compiler |
|
Version |
|
VVRRTPPPP |
VV = Version |
Identification |
|
C++ compiler |
|
Version |
|
As __DECC_VER |
|
Identification |
|
Obsolete |
|
Identification |
|
Obsolete |
Example
Compaq C/C++ |
|
6.0-001 |
60090001 |
Convex C
Type |
Macro |
Identification |
|
CompCert
Type |
Macro |
Identification |
|
Coverity C/C++ Static Analyzer
Type |
Macro |
Identification |
|
Cray C
Type |
Macro |
Description |
Identification |
|
|
Version |
|
Version |
Version |
|
Revision |
Diab C/C++
Type |
Macro |
Format |
Description |
Identification |
|
1 |
|
Version |
|
VRPP |
V = Version |
Example
Diab C/C++ |
|
4.4g |
4426 |
DICE C
Type |
Macro |
Identification |
|
Digital Mars
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
0xVRP |
V = Version |
Example
Digital Mars |
|
7.0 |
0x700 |
7.2 |
0x720 |
8.0 |
0x800 |
Dignus Systems/C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRRPP |
V = Version |
Example
Systems/C |
|
1.80.32 |
18032 |
DJGPP
Type |
Macro |
Description |
Identification |
|
|
Version |
|
Version |
Version |
|
Revision |
Identification |
|
Defined by DJGPP 1.x |
Example
DJGPP |
|
|
2.01 |
2 |
1 |
EDG C++ Frontend
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRR |
V = Version |
Example
EDG C++ |
|
2.30 |
230 |
2.45 |
245 |
EKOPath
Type |
Macro |
Description |
Identification |
|
|
Version |
|
Version |
Version |
|
Revision |
Version |
|
Patch |
Example
EKOPath |
|
|
|
2.0 |
2 |
0 |
0 |
Fujitsu C++
Type |
Macro |
Identification |
|
GCC C/C++
Type |
Macro |
Description |
Identification |
|
|
Version |
|
Version |
Version |
|
Revision |
Version |
|
Patch (introduced in version 3.0) |
Notice that the meaning of the __GNUC__
macro has changed subtly over the years, from identifying the GNU C/C++ compiler to identifying any compiler that implements the GNU compiler extensions (see the Feature request - a macro defined for GCC discussion for further information). For example, the Intel C++ on Linux also defines these macros from version 8.1 (see the Intel C++ Compiler 8.1 for Linux Release Notes and Intel Compilers for Linux: Compatibility with GNU Compilers.)
Example
GNU C/C++ |
|
|
|
2.7.x |
2 |
7 |
N/A |
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 |
|
VVRRPP |
VV = Version |
Example of Alternative Version
GNU C/C++ |
|
2.7.x |
20700 |
3.0.2 |
30002 |
Green Hill C/C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRP |
V = Version |
Version |
|
Example
Green Hill C/C++ |
|
4.2.1 |
421 |
HP ANSI C
Type |
Macro |
Identification |
|
HP aC++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
1 |
From version A.01.15 (and A.03.13) |
Version |
|
VVRRPP |
VV = Version |
Example
HP aCC |
|
A.01.21 |
12100 |
IAR C/C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRR |
V = Version |
Example
IAR C/C++ |
|
3.34 |
334 |
IBM XL C/C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
||
Version |
|
0xVVRR |
VV = Version |
Version |
|
0x0000PPBB |
PP = Patch |
Identification |
|
From ? |
|
Identification |
|
From ? |
|
Version |
|
VRP |
V = Version |
Notice 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++ |
|
|
3.1 |
0x0301 |
|
4.5 |
0x0405 |
|
5.0 |
0x0500 |
|
12.01.0000.0004 |
0x0C01 |
0x00000004 |
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 |
|
||
Identification |
|
||
Version |
|
NVRRM |
N = Product (0 = C/370, 1 = MVS, 2 = OS/390, 4 = z/OS) |
Version |
|
0xNVRRPPPP |
N = Product (see above) |
Notice 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. Alternatively, the macro identifying z/OS (__MVS__
) can be used to distinguish between them.
#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++ |
|
|
1.7 |
41070 |
0x41070000 |
1.13 |
41130 |
0x410D0000 |
ImageCraft C
Type |
Macro |
Identification |
|
Intel C/C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
Obsolete |
|
Identification |
|
Obsolete |
|
Identification |
|
||
Version |
|
VRP |
V = Version |
Version |
|
YYYYMMDD |
YYYY = Year |
Example
Intel C/C++ |
|
|
5.0 |
500 |
|
6.0 |
600 |
|
8.0 |
800 |
|
9.0 |
900 |
20060222 |
KAI C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
0xVRPP |
V = Version |
Example
KAI C++ |
|
4.0d |
4004 |
KEIL CARM
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
||
Version |
|
VRR |
V = Version |
Example
Keil CARM |
|
1.01 |
101 |
KEIL C166
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRR |
V = Version |
Example
Keil C166 |
|
5.01 |
501 |
KEIL C51
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
||
Version |
|
VRR |
V = Version |
Example
Keil C51 |
|
7.01 |
701 |
LCC
Type |
Macro |
Identification |
|
LLVM
Type |
Macro |
Identification |
|
MetaWare High C/C++
Type |
Macro |
Identification |
|
Metrowerks CodeWarrior
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
From 4.2.0 |
|
Version |
|
1 |
Until CodeWarrior 7 |
Version |
|
0xVRPP |
V = Version |
Version |
|
0xVRPP |
V = Version |
Example
Metrowerks C/C++ |
|
|
2.0 |
0x2000 |
|
2.2 |
0x2200 |
|
4.2.0 |
0x4200 |
0x4200 |
Microsoft Visual C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VVRR |
VV = Version |
Version |
|
VVRRPPPP |
VV = Version |
Version |
|
VVRRPPPPP |
VV = Version |
Version |
|
B |
B = Build number |
Example
|
|
|
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 |
9.0 (2008) |
1500 |
150021022 |
9.0 SP1 |
1500 |
150030729 |
10.0 (2010) |
1600 |
160030319 |
10.0 (2010) SP1 |
1600 |
160040219 |
11.0 (2012) |
1700 |
170050727 |
12.0 (2013) |
1800 |
180021005 |
14.0 (2015) |
1900 |
190023026 |
14.0 (2015 Update 1) |
1900 |
190023506 |
14.0 (2015 Update 2) |
1900 |
190023918 |
14.0 (2015 Update 3) |
1900 |
190024210 |
15.0 (2017) |
1910 |
191025017 |
Microtec C/C++
Type |
Macro |
Identification |
|
Microway NDP C
Type |
Macro |
Identification |
|
MinGW and MinGW-w64
MinGW (formerly known as MinGW32) is a toolchain for creating 32 Bit Windows executables. The MinGW-w64 projects offers toolchains for creating 32 Bit and 64 Bit Windows executables. The following table shows which macros are defined by each toolchain:
Type |
Macro |
Description |
MinGW32 |
MinGW-w64 32 Bit |
MinGW-w64 64 Bit |
Identification |
|
defined |
defined |
defined |
|
Version |
|
Version |
defined |
defined |
defined |
Version |
|
Revision |
defined |
defined |
defined |
Identification |
|
- |
- |
defined |
|
Version |
|
Version |
- |
defined |
defined |
Version |
|
Revision |
- |
defined |
defined |
Notice that __MINGW32_MAJOR_VERSION
, __MINGW32_MINOR_VERSION
, __MINGW64_VERSION_MAJOR
, and __MINGW64_VERSION_MINOR
are only defined if appropriate headers are included. Appropriate headers are
<stdlib.h>
, <stdio.h>
, <windows.h>
, <windef.h>
, and probably more.
Examples
|
|
|
|
Description |
2 |
4 |
MinGW32 2.4 |
||
3 |
20 |
MinGW32 3.20 |
||
3 |
11 |
2 |
0 |
MinGW-w64 2.0 |
MIPSpro
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
||
Version |
|
VRP |
V = Version |
Version |
|
VRP |
V = Version |
Example
MIPSpro |
|
|
6.0.2 |
602 |
|
7.2.1 |
721 |
|
7.4.4 |
744 |
Miracle C
Type |
Macro |
Identification |
|
MPW C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
||
Identification |
|
||
Version |
|
0xVVRR |
VV = Version |
Example
MPW C++ |
|
5.0 |
0x500 |
Norcroft C
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
V.R |
V = Version |
Notice that __ARMCC_VERSION
is assigned a floating-point number, so it cannot be used by the preprocessor to compare versions.
Example
Norcroft C |
|
4.69 |
4.69 |
4.90 |
4.90 |
NWCC
Type |
Macro |
Identification |
|
Open64
Type |
Macro |
Format |
Description |
Identification |
|
Contains the full version as a string |
|
Identification |
|
||
Version |
|
V |
V = Version |
Version |
|
R |
R = Revision |
Version |
|
P.B |
P = Patch |
Notice that __OPENCC_PATCHLEVEL__
can be a floating-point number (e.g. 5.2
for Open64 version 4.2.5.2) so it cannot be used by the preprocessor to compare patch-levels.
Oracle Pro*C Precompiler
Type |
Macro |
Identification |
|
Oracle Solaris Studio
Type |
Macro |
Format |
Description |
Identification |
|
C compiler |
|
Version |
|
0xVRP |
V = Version |
Version |
|
0xVRRP |
V = Version |
Identification |
|
C++ compiler |
|
Version |
|
As |
Example
Compiler version |
Solaris Studio |
|
4.2 |
4.2 |
0x420 |
5.0 |
5.0 |
0x500 |
5.2 |
6.1 |
0x520 |
5.3 |
6.2 |
0x530 |
5.4 |
7 |
0x540 |
5.5 |
8 |
0x550 |
5.6 |
9 |
0x560 |
5.7 |
10 |
0x570 |
5.8 |
11 |
0x580 |
5.9 |
12 |
0x590 |
5.10 |
12.1 |
0x5100 |
5.11 |
12.2 |
0x5110 |
5.12 |
12.3 |
0x5120 |
The name of Oracle Solaris Studio has changed over the years (e.g. Sun Studio, Sun Workshop, Forte Developer) but we do not make this distinction in the table above.
Pacific C
Type |
Macro |
Identification |
|
Palm C/C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
0xVRRPPBBB |
V = Version |
Example
Palm C/C++ |
|
1.0.0.13 |
0x1000000D |
Pelles C
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRR |
V = Version |
Example
Pelles C |
|
3.00 |
300 |
Portland Group C/C++
Type |
Macro |
Description |
Identification |
|
|
Version |
|
Version |
Version |
|
Revision |
Version |
|
Patch |
Example
PGI C/C++ |
|
|
|
7.0.1 |
7 |
0 |
1 |
11.9 |
11 |
9 |
0 |
Renesas C/C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
||
Version |
|
0xVVRR |
V = Version |
Version |
|
0xVVRRPP00 |
From ? |
Version |
|
0xVVRR |
As above |
Example
Renesas C/C++ |
|
|
5.1C |
0x0501 |
|
8.0 |
0x8000 |
0x8000 |
1.00.00 |
0x01000000 |
SAS/C
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
||
Identification |
|
||
Version |
|
Until ? |
|
Version |
|
Until ? |
|
Version |
|
VRR |
V = Version |
Example
SAS/C |
|
|
|
5.10 |
5 |
10 |
|
6.50 |
650 |
SCO OpenServer
Type |
Macro |
Identification |
|
Small Device C Compiler
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRP |
V = Version |
Example
SDCC Version |
|
2.5.6 |
256 |
SN Compiler
Type |
Macro |
Identification |
|
Stratus VOS C
Type |
Macro |
Description |
Identification |
|
|
Version |
|
0 = K&R compiler |
Symantec C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
0xVVRR |
VV = Version |
TenDRA C/C++
Type |
Macro |
Identification |
|
Texas Instruments C/C++ Compiler
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
All C6000 compilers |
|
Version |
|
VVVRRRPPP |
VVV = Version |
Example
TI C/C++ |
|
4.9.1 |
4009001 |
7.3.1 |
7003001 |
THINK C
Type |
Macro |
Description |
Version |
|
Version 3.x |
Version |
|
Version 4.x |
Tiny C
Type |
Macro |
Identification |
|
Turbo C/C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
0xVVRR |
VV = Version |
Example
Turbo C |
Turbo C++ |
|
2.01 |
0x201 |
|
1.00 |
0x295 |
|
1.01 |
0x296 |
|
2.00 |
0x297 |
Ultimate C/C++
Type |
Macro |
Description |
Identification |
|
|
Version |
|
V = Version |
Example
Ultimate C/C++ |
|
|
2.1 |
2 |
1 |
USL C
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRRYYYYMM |
V = Version |
Example
USL C |
|
Description |
3.2 |
302199801 |
|
3.4 |
304200805 |
UnixWare 7.1.4 UDK C++ (CC) |
4.2 |
402200805 |
UnixWare 7.1.4 UDK C (cc) |
VBCC
Type |
Macro |
Identification |
|
Watcom C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VVRR |
VV = Version |
Notice that Watcom C++ became Open Watcom C++ after version 11.0, and the official version numbering (but not the version macro) was restated at version 1.0.
Example
Watcom C++ |
Open Watcom C++ |
|
10.5 |
1050 |
|
11.0 |
1100 |
|
1.0 |
1200 |
|
1.7 |
1270 |
Zortech C++
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
0xVRP |
V = Version |
Top
Standard C Libraries
Bionic libc
The following macro is defined in the <sys/cdefs.h>
header file. It may be best to include it via the <sys/types.h>
header file, which is required by POSIX.
Type |
Macro |
Idenfication |
|
GNU glibc
The following macros have to be included from the <features.h>
header file.
Type |
Macro |
Description |
Version |
|
Until version 5 |
Version |
|
From version 6 |
Notice that the <features.h>
header file does not exist on all platforms, so it cannot be included without further ado. However, since it is included by other GNU glibc header files, a better way to obtain the above-mentioned macros is to include the <limits.h>
header file (see e.g. paragraph 4/6 in ISO/IEC 9899:1999).
klibc
Type |
Macro |
Format |
Description |
Identification |
|
Zero is a valid value |
|
Version |
|
Version |
|
Version |
|
Revision |
|
Version |
|
Patch |
|
Version |
|
0xVVRRPPPP |
VV = Version |
uClibc
The following macros have to be included from the <features.h>
header file.
Type |
Macro |
Description |
Identification |
|
|
Version |
|
Version |
Version |
|
Revision |
Version |
|
Patch |
VMS libc
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VVRREPPTT |
VV = Version |
Notice that I am not sure about the format of __CRTL_VER
, but it seems to follow that of __VMS_VER
.
z/OS libc
Type |
Macro |
Format |
Description |
Identification |
|
Host |
|
Identification |
|
Target |
|
Version |
|
0xNVRRPPPP |
N = Product (0 = C/370, 1 = MVS, 2 = OS/390, 4 = z/OS) |
Version |
|
As above |
Example
Library |
|
OS/390 2.10 |
0x220A0000 |
z/OS 1.1 |
0x41010000 |
z/OS 1.6 |
0x41060000 |
Standard C++ Libraries
Dinkumware
Type |
Macro |
Format |
Description |
Identification |
|
Defined for Dinkumware 2.0 and later |
|
Version |
|
VVRR |
VV = Version |
Example
Dinkumware |
Visual C++ |
|
3.06 |
306 |
|
3.08 |
308 |
|
4.05 |
2005 |
405 |
5.03 |
2008 |
503 |
5.05 |
2008 SP1 |
505 |
5.20 |
2010 |
520 |
5.40 |
2012 |
540 |
6.10 |
2013 |
610 |
GNU libstdc++
One of the standard header files must be included before any of the following macros are defined.
Type |
Macro |
Format |
Description |
Version |
|
YYYYMMDD |
YYYY = Year |
Version |
|
YYYYMMDD |
YYYY = Year |
Example
GCC |
|
|
3.0.0 |
20010615 |
|
3.1.0 |
20020514 |
|
3.2.0 |
20020814 |
|
3.3.0 |
20030513 |
|
3.4.0 |
20040419 |
Intel C++ Run-Time Libraries
Type |
Macro |
Identification |
|
libc++
One of the standard header files must be included before any of the following macros are defined.
Type |
Macro |
Format |
Description |
Version |
|
VRRR |
V = Version |
Version |
|
V |
V = ABI Version |
Other Libraries
Microsoft Foundation Classes
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
0xVVRR |
VV = Version |
Example
MFC |
|
4.21 |
0x0421 |
6.0 |
0x0600 |
7.0 |
0x0700 |
Top
OperatingSystems
AIX
Type |
Macro |
Description |
Identification |
|
|
Version |
|
V = Version |
Identification |
|
Defined by xlC |
Example
If _AIX
is defined, then the following macros can be used to determine the version. Notice that the macros indicates the mentioned version or higher. For example, if _AIX43
is defined, then _AIX41
will also be defined.
AIX Version |
Macro |
3.2.x |
|
4.1 |
|
4.3 |
|
Android
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
V |
V = API Version |
Notice that Android is based on Linux, and that the Linux macros also are defined for Android.
Example
Android Version |
|
1.0 |
1 |
1.1 |
2 |
1.5 |
3 |
1.6 |
4 |
2.0 |
5 |
2.0.1 |
6 |
2.1 |
7 |
2.2 |
8 |
2.3 |
9 |
2.3.3 |
10 |
3.0 |
11 |
Amdahl UTS
Type |
Macro |
Identification |
|
AmigaOS
Type |
Macro |
Description |
Identification |
|
|
Identification |
|
Defined by GNU C |
Apollo AEGIS
Type |
Macro |
Identification |
|
Apollo Domain/OS
Type |
Macro |
Identification |
|
Bada
Based on Nucleus OS.
BeOS
Type |
Macro |
Identification |
|
Blue Gene
Type |
Macro |
Description |
Identification |
|
All Blue Gene systems |
Version |
|
Blue Gene/Q |
Identification |
|
All Blue Gene systems |
Version |
|
Blue Gene/Q |
BSD Environment
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
YYYYMM |
YYYY = Year |
Version |
|
Must be included from |
|
Identification |
|
Defined by DEC C |
Example
Version |
|
Macro |
4.3 Net2 |
199103 |
|
4.4 |
199306 |
|
4.4BSD-Lite2 |
199506 |
BSD/OS
Type |
Macro |
Identification |
|
ConvexOS
Type |
Macro |
Identification |
|
Cygwin Environment
Type |
Macro |
Identification |
|
DG/UX
Type |
Macro |
Identification |
|
Identification |
|
Identification |
|
DragonFly
Type |
Macro |
Identification |
|
DYNIX/ptx
Type |
Macro |
Identification |
|
Identification |
|
eCos
Type |
Macro |
Identification |
|
EMX Environment
Type |
Macro |
Identification |
|
FreeBSD
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
From FreeBSD 8.3, 9.1, and 10.0.1 |
|
Version |
|
||
Version |
|
V |
V = Version |
Version |
|
? |
Must be included from |
Example
FreeBSD |
|
|
1.x |
1 |
|
2.0-RELEASE |
2 |
119411 |
2.2-RELEASE |
2 |
220000 |
3.0-RELEASE |
3 |
300005 |
4.0-RELEASE |
4 |
400017 |
4.5-RELEASE |
4 |
450000 |
For more information see the FreeBSD porters handbook.
GNU aka GNU/Hurd
The official name of this operating system is GNU. Hurd is the kernel in the GNU operating system. It is often listed as GNU/Hurd since there is also GNU/Linux and GNU/kFreeBSD, which are most of the GNU operating system with the Linux and FreeBSD kernels respectively.
Type |
Macro |
Identification |
|
Identification |
|
GNU/kFreeBSD
GNU/kFreeBSD is one of the Debian distros that is based on the FreeBSD kernel rather than the Linux or Hurd kernels.
Type |
Macro |
Identification |
|
Notice that FreeBSD also defines __FreeBSD_kernel__
so the __GLIBC__
macro must be checked to distinguish it.
GNU/Linux
Type |
Macro |
Identification |
|
HI-UX MPP
Type |
Macro |
Identification |
|
HP-UX
Type |
Macro |
Description |
Identification |
|
Defined by HP UPC |
Identification |
|
|
Identification |
|
IBM OS/400
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
VRM |
V = Version |
INTEGRITY
Type |
Macro |
Identification |
|
Interix Environment
Type |
Macro |
Description |
Identification |
|
Defined by GNU C and Visual Studio |
IRIX
Type |
Macro |
Identification |
|
Identification |
|
Linux kernel
Systems based on the Linux kernel define these macros. There are two major Linux-based operating systems: GNU/Linux and Android, and numerous others like Ångström or OpenEmbedded
Type |
Macro |
Description |
Identification |
|
|
Identification |
|
Obsolete (not POSIX compliant) |
Identification |
|
Obsolete (not POSIX compliant) |
LynxOS
Type |
Macro |
Identification |
|
MacOS
Type |
Macro |
Description |
Identification |
|
Mac OS 9 |
Identification |
|
Mac OS 9 |
Identification |
|
Mac OS X |
Microware OS-9
Type |
Macro |
Description |
Identification |
|
Defined by Ultimate C/C++ |
Identification |
|
Defined by Ultimate C/C++ |
MINIX
Type |
Macro |
Identification |
|
MorphOS
Type |
Macro |
Identification |
|
MPE/iX
Type |
Macro |
Identification |
|
Identification |
|
MSDOS
Type |
Macro |
Identification |
|
Identification |
|
Identification |
|
Identification |
|
NetBSD
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
||
Version |
|
V = Version |
|
Version |
|
VVRRAAPP00 |
VV = Version |
Version |
|
VVRR00PP00 |
VV = Version |
Example
NetBSD |
|
Macro |
0.8 |
|
|
0.9 |
|
|
1.0 |
|
|
1.0A |
|
|
1.2D |
102040000 |
|
1.2.1 |
102000100 |
NonStop
Type |
Macro |
Identification |
|
Nucleus RTOS
Type |
Macro |
Identification |
|
OpenBSD
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
||
Version |
|
V = Version |
Example
OpenBSD |
Macro |
3.1 |
|
3.9 |
|
OS/2
Type |
Macro |
Identification |
|
Identification |
|
Identification |
|
Identification |
|
Palm OS
Type |
Macro |
Description |
Identification |
|
Defined by GNU C in PRC-Tools |
Plan 9
Type |
Macro |
Identification |
|
Pyramid DC/OSx
Type |
Macro |
Identification |
|
QNX
Type |
Macro |
Format |
Description |
Identification |
|
QNX 4.x |
|
Identification |
|
QNX 6.x |
|
Version |
|
VRR |
V = Version |
Version |
|
VVRRRRPPPP |
V = Version |
Example
QNX |
|
6.2 |
620 |
Reliant UNIX
Type |
Macro |
Identification |
|
SCO OpenServer
Type |
Macro |
Description |
Identification |
|
Defined by GNU C |
Identification |
|
Defined by GNU C |
Identification |
|
Solaris
Type |
Macro |
Description |
Identification |
|
|
Identification |
|
|
Version |
|
System = |
Use the SVR4 macros to distinguish between Solaris and SunOS.
#if defined(sun) || defined(__sun)
# if defined(__SVR4) || defined(__svr4__)
/* Solaris */
# else
/* SunOS */
# endif
#endif
Example
Solaris |
Macro |
2.7 |
|
8 |
|
Stratus VOS
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
V |
V = Version |
Notice that the __VOS__
macro is defined by the compiler, but as several compilers can co-exist in the same OS release, the version number is not reliable.
SVR4 Environment
Type |
Macro |
Description |
Identification |
|
|
Identification |
|
|
Identification |
|
|
Identification |
|
Defined on IRIX |
Syllable
Type |
Macro |
Identification |
|
Symbian OS
Type |
Macro |
Identification |
|
Tru64 (OSF/1)
Type |
Macro |
Identification |
|
Identification |
|
Ultrix
Type |
Macro |
Identification |
|
Identification |
|
Identification |
|
Identification |
|
UNICOS
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
V |
V = Version |
UNICOS/mp
Type |
Macro |
Description |
Identification |
|
UNIX Environment
Type |
Macro |
Identification |
|
Identification |
|
Notice that not all compilers defines these macros, e.g. the xlC or the DEC C/C++ compiler, so it may be better to use the POSIX or X/Open standard macros instead.
UnixWare
Type |
Macro |
Identification |
|
Identification |
|
U/Win Environment
Type |
Macro |
Identification |
|
VMS
Type |
Macro |
Format |
Description |
Identification |
|
||
Identification |
|
||
Version |
|
VVRREPPTT |
VV = Version |
Example
VMS |
|
6.1 |
60100022 |
6.2 |
60200022 |
6.2-1I |
60210922 |
VxWorks
Type |
Macro |
Description |
|
Identification |
|
Defined by GNU C and Diab (from ?) |
|
Identification |
|
Defined by GNU C and Diab (from ?) |
|
Version |
|
Version |
|
Version |
|
Revision |
|
Version |
|
Patch/maintenance |
|
Mode |
|
For real-time mode |
|
Mode |
|
For kernel mode |
Example
VxWorks |
|
|
|
6.2 |
6 |
2 |
0 |
Windows
Type |
Macro |
Description |
Identification |
|
Defined for 16-bit environments 1 |
Identification |
|
Defined for both 32-bit and 64-bit environments 1 |
Identification |
|
Defined for 64-bit environments 1 |
Identification |
|
Defined by Borland C++ |
Identification |
|
Defined by xlC |
Identification |
|
Defined by Watcom C/C++ |
Windows CE
Type |
Macro |
Format |
Description |
Identification |
|
Defined by Embedded Visual Studio C++ |
|
Version |
|
VRR |
V = Version |
Identification |
|
P = Platform |
|
Version |
|
V |
P = Platform |
Example
Version |
|
2.01 |
201 |
2.11 |
211 |
3.0 |
300 |
4.0 |
400 |
4.1 |
410 |
4.2 |
420 |
5.0 |
501 |
Platform |
Macro |
Value |
H/PC 2000 |
|
|
H/PC Pro 2.11 |
|
211 |
H/PC Pro 3.0 |
|
300 |
Pocket PC |
|
1 |
Pocket PC 2002 |
|
310 |
Windows Mobile 2003 |
|
400 |
Smartphone 2002 |
|
100 |
Wind/U Environment
Type |
Macro |
Format |
Description |
Identification |
|
||
Version |
|
0xVVRRPP |
VV = Version |
Example
Wind/U |
|
3.1.2 |
0x030102 |
z/OS
Type |
Macro |
Description |
Identification |
|
Host |
Identification |
|
Host |
Identification |
|
Target |
Top
Architectures
Alpha
Type |
Macro |
Description |
Identification |
|
Defined by GNU C |
Version |
|
V = Version |
Identification |
|
Defined by DEC C |
Identification |
|
Defined by Visual Studio |
Example
CPU |
Macro |
Alpha EV4 |
|
Alpha EV5 |
|
Alpha EV6 |
|
AMD64
Type |
Macro |
Description |
Identification |
|
Defined by GNU C and Sun Studio |
Identification |
_M_X64 |
Defined by Visual Studio |
Notice that x32 can be detected by checking if the CPU uses the ILP32 data model.
ARM
Type |
Macro |
Description |
Identification |
|
Defined by GNU C and RealView |
Identification |
|
Defined by GNU C and RealView in Thumb mode |
Version |
|
V = Version |
Identification |
|
Defined by RealView |
Version |
|
V = Version |
Version |
|
VR = Version and Revision |
Identification |
|
Defined by ImageCraft C |
Identification |
|
Defined by Visual Studio |
Identification |
|
Defined by Visual Studio in Thumb mode |
Version |
|
V = Version |
Identification |
|
Defined by Diab |
Example
CPU |
Macro |
|
ARM 2 |
|
|
ARM 3 |
|
|
ARM 4T |
|
|
ARM 5 |
|
5 |
ARM 5T |
|
|
ARM 6 |
|
6 |
ARM 6T2 |
|
|
ARM 7 |
|
7 |
ARM64
Type |
Macro |
Description |
Identification |
|
Defined by GNU C 1 |
Blackfin
Type |
Macro |
Description |
Identification |
|
Defined by GNU C |
Convex
Type |
Macro |
Description |
Identification |
|
Defined by GNU C |
Version |
|
V = Version |
Example
CPU |
Macro |
Convex C1 |
|
Convex C2 |
|
Convex C32xx series |
|
Convex C34xx series |
|
Convex C38xx series |
|
Epiphany
Type |
Macro |
|
Identification |
|
HP/PA RISC
Type |
Macro |
Description |
Identification |
|
Defined by GNU C |
Identification |
|
Defined by Stratus VOS C |
Identification |
|
|
Version |
|
V = Version |
See also OpenPA.net.
Example
CPU |
Macro |
PA RISC 1.0 |
|
PA RISC 1.1 |
|
PA RISC 2.0 |
|
Intel x86
Type |
Macro |
Format |
Description |
Identification |
|
Defined by GNU C |
|
Version |
|
Defined by GNU C |
|
Identification |
|
Defined by Sun Studio |
|
Identification |
|
Defined by Stratus VOS C |
|
Identification |
|
Only defined for 16-bits architectures |
|
Identification |
|
Only defined for 32-bits architectures |
|
Version |
|
V00 |
V = Version |
Identification |
|
Defined by Watcom C/C++ |
|
Identification |
|
Defined by MinGW32 |
|
Identification |
|
Defined by XL C/C++ |
|
Identification |
|
Defined by Digital Mars |
|
Version |
|
V |
V = Version |
Identification |
|
Defined by CodeWarrior |
|
Identification |
|
Defined by Diab |
Notice that Watcom C/C++ defines _M_IX86
for both 16-bits and 32-bits architectures. Use __386__
or _M_I386
to detect 32-bits architectures in this case.
Notice that the Stratus VOS is big-endian on IA32, so these macros cannot be used to detect endianness if __VOS__
is set.
Example
CPU |
|
|
80386 |
300 |
3 |
80486 |
400 |
4 |
Pentium |
500 |
5 |
Pentium Pro/II |
600 |
6 |
Intel Itanium (IA-64)
Type |
Macro |
Format |
Description |
Identification |
|
Defined by GNU C |
|
Identification |
|
Defined by HP aCC |
|
Identification |
|
Defined by Visual Studio |
|
Identification |
|
Defined by Intel C/C++ |
|
Version |
|
? |
|
Identification |
|
Defined by Intel C/C++ |
Example
CPU |
|
64100 |
Motorola 68k
Type |
Macro |
Description |
Identification |
|
Defined by GNU C |
Version |
|
V = Version |
Identification |
|
Defined by SAS/C |
Identification |
|
Defined by Stratus VOS C |
Version |
|
V = Version |
Example
CPU |
Macro |
68000 |
|
68010 |
|
68020 |
|
68030 |
|
68040 |
|
68060 |
|
MIPS
Type |
Macro |
Description |
Identification |
|
Defined by GNU C |
Version |
|
V = MIPS ISA level |
Version |
|
|
Identification |
|
Defined by MIPSpro and GNU C |
Version |
|
The value indicates the MIPS ISA (Instruction Set Architecture) level |
Version |
|
V = MIPS ISA level |
Identification |
|
Defined by Metrowerks |
Example
CPU |
|
GNU C Macro |
|
MIPSpro Macro |
R2000 |
|
1 |
||
R3000 |
|
|
1 |
|
R6000 |
|
2 |
|
|
R4000 |
|
|||
R4400 |
|
3 |
|
|
R8000 |
|
4 |
|
|
R10000 |
|
4 |
|
PowerPC
Type |
Macro |
Description |
Identification |
|
Defined by GNU C |
Version |
|
V = Version |
Identification |
|
Defined by Visual Studio |
Version |
|
? |
Identification |
|
Defined by XL C/C++ |
Version |
|
V = Version |
Version |
|
Gekko |
Version |
|
Broadway |
Version |
|
|
Identification |
|
Defined by Diab |
Example
CPU |
|
Macro |
XL Macro |
PowerPC 440 |
|
||
PowerPC 450 |
|
||
PowerPC 601 |
601 |
|
|
PowerPC 603 |
603 |
|
|
PowerPC 604 |
604 |
|
|
PowerPC 620 |
620 |
Pyramid 9810
Type |
Macro |
Identification |
|
RS/6000
Type |
Macro |
Description |
Identification |
|
Defined by XL C/C++ |
Identification |
|
|
Identification |
|
|
Identification |
|
SPARC
Type |
Macro |
Description |
Identification |
|
Defined by GNU C |
Identification |
|
Defined by Sun Studio |
Version |
|
Defined by GNU C |
Version |
|
Defined by Sun Studio |
Example
CPU |
Sun Studio Macro |
GNU C Macro |
SPARC v8 (SuperSPARC) |
|
|
SPARC v9 (UltraSPARC) |
|
|
SuperH
Type |
Macro |
Description |
Identification |
|
Defined by GNU C |
Version |
|
SystemZ
Type |
Macro |
Description |
Identification |
|
Identifies System/370 |
Identification |
|
Identifies System/390 |
Identification |
|
Identifies z/Architecture |
Identification |
|
Identifies z/Architecture |
Identification |
|
Identifies z/Architecture |
TMS320
Type |
Macro |
Description |
Identification |
|
C2000 series |
Identification |
|
C5000 series |
Identification |
|
C6000 series |
Example
DSP |
Macro |
C28xx |
|
C54x |
|
C55x |
|
C6200 |
|
C6400 |
|
C6400+ |
|
C6600 |
|
C6700 |
|
C6700+ |
|
C6740 |
|
TMS470
Type |
Macro |
Identification |
|
Related
Wiki: Architectures
Wiki: Compilers
Wiki: Endianness
Wiki: FeatureMacros
Wiki: Libraries
Wiki: OperatingSystems
Wiki: Standards
Wiki: VersionNormalization