OperatingSystems.md

July 5, 2025 · View on GitHub

Please send updates/corrections to predef-contribute or through pull requests on GitHub.

AIX

TypeMacroDescription
Identification_AIX
Version_AIX'VR'V = Version
R = Revision
Identification__TOS_AIX__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 VersionMacro
3.2.x_AIX3
_AIX32
4.1_AIX41
4.3_AIX43

Android

TypeMacroFormatDescription
Identification__ANDROID__
Version__ANDROID_API__VV = API Version

Must be included from <android/api-level.h>

Notice that Android uses Linux kernel, and that the Linux macros also are defined for Android.

Example
Android Version__ANDROID_API__
1.01
1.12
1.53
1.64
2.05
2.0.16
2.17
2.28
2.39
2.3.310
3.011

Amdahl UTS

TypeMacro
IdentificationUTS

AmigaOS

TypeMacroDescription
IdentificationAMIGA
Identification__amigaos__Defined by GNU C

Apollo AEGIS

TypeMacro
Identificationaegis

Apollo Domain/OS

TypeMacro
Identificationapollo

AROS

Originally Amiga Research Operating System, later renamed to AROS Research Operating System.

TypeMacro
Identification__AROS__

Bada

Based on Nucleus OS.

BeOS

TypeMacroFormatDescription
Identification__BEOS__
VersionB_BEOS_VERSION0xVVRRVV = Version
RR = Revision

Must be included from <BeBuild.h>

Blue Gene

TypeMacroDescription
Identification__bg__All Blue Gene systems

Defined by XL C/C++ and GNU C
Version__bgq__Blue Gene/Q

Defined for XL C/C++ and GNU C
Identification__THW_BLUEGENE__All Blue Gene systems

Defined by XL C/C++
Version__TOS_BGQ__Blue Gene/Q

Defined by XL C/C++

BSD Environment

TypeMacroFormatDescription
Identification__FreeBSD__
__NetBSD__
__OpenBSD__
__bsdi__
__DragonFly__
__MidnightBSD__
VersionBSDYYYYMMYYYY = Year
MM = Month

Must be included from <sys/param.h>
VersionBSD4_2
BSD4_3
BSD4_4
Must be included from <sys/param.h>
Identification_SYSTYPE_BSDDefined by DEC C
Example
VersionBSDMacro
4.3 Net2199103
4.4199306BSD4_4
4.4BSD-Lite2199506

BSD/OS

TypeMacro
Identification__bsdi__

ConvexOS

TypeMacro
Identification__convex__

CP/M

TypeMacroFormatDescription
Identification__CPMDefined by Z88DK
IdentificationCPMDefined by Z88DK

Cygwin Environment

TypeMacro
Identification__CYGWIN__

DG/UX

TypeMacro
IdentificationDGUX
Identification__DGUX__
Identification__dgux__

DragonFly

TypeMacro
Identification__DragonFly__

DYNIX/ptx

TypeMacro
Identification_SEQUENT_
Identificationsequent

eCos

TypeMacro
Identification__ECOS

Emscripten

TypeMacroFormatDescription
IdentificationEMSCRIPTENFrom Emscripten 1.0.1a until Emscripten 1.30.6
Identification__EMSCRIPTEN__From Emscripten 1.3.7
Version__EMSCRIPTEN_major__VV = Major version

From Emscripten 1.21.4

Must be included from <emscripten/version.h>
Version__EMSCRIPTEN_minor__RR = Minor version

From Emscripten 1.21.4

Must be included from <emscripten/version.h>
Version__EMSCRIPTEN_tiny__PP = Patch level

From Emscripten 1.21.4

Must be included from <emscripten/version.h>

For more information see Detecting Emscripten in Preprocessor

Example
Version__EMSCRIPTEN_major____EMSCRIPTEN_minor____EMSCRIPTEN_tiny__
3.1.413141
3.1.41-git3141

EMX Environment

TypeMacro
Identification__EMX__

FreeBSD

TypeMacroFormatDescription
Identification__FreeBSD__
Identification__FreeBSD_kernel__From FreeBSD 8.3, 9.1, and 10.0.1
VersionBSD
Version__FreeBSD__VV = Version
Version__FreeBSD_version?Must be included from <sys/param.h>
Example
FreeBSD__FreeBSD____FreeBSD_version
1.x1
2.0-RELEASE2119411
2.2-RELEASE2220000
3.0-RELEASE3300005
4.0-RELEASE4400017
4.5-RELEASE4450000

For more information see the FreeBSD porters handbook.

Fuchsia

TypeMacroFormatDescription
Identification__Fuchsia__1
Version__Fuchsia_API_level__VV = API level 1

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.

TypeMacro
Identification__GNU__ 1
Identification__gnu_hurd__ 1

GNU/kFreeBSD

GNU/kFreeBSD is one of the Debian distros that is based on the FreeBSD kernel rather than the Linux or Hurd kernels.

TypeMacro
Identification__FreeBSD_kernel__ && __GLIBC__

Notice that FreeBSD also defines __FreeBSD_kernel__ so the __GLIBC__ macro must be checked to distinguish it.

GNU/Linux

TypeMacro
Identification__gnu_linux__

Haiku

TypeMacroFormatDescription
Identification__HAIKU__
VersionB_HAIKU_VERSION_'V'0x00VV0000VV = Version

Defined in advance before being reached.

Must be included from <BeBuild.h>
VersionB_HAIKU_VERSION0x00VVRRPPVV = Version
RR = Revision (Alpha and Beta ordering for VV+1)
PP = Pre (0 or 1 if before RR+1)

Must be included from <BeBuild.h>
Example
HaikuB_HAIKU_VERSION
1 Alpha 1B_HAIKU_VERSION_1_ALPHA_1 = 0x00000100
1 Alpha 4B_HAIKU_VERSION_1_ALPHA_4 = 0x00000400
1 Beta 1B_HAIKU_VERSION_1_BETA_1 = 0x00000500
Git version before 1 Beta 4B_HAIKU_VERSION_1_PRE_BETA_4 = 0x00000701
1B_HAIKU_VERSION_1 = 0x00010000

HI-UX MPP

TypeMacro
Identification__hiuxmpp

HP-UX

TypeMacroDescription
Identification_hpuxDefined by HP UPC
Identificationhpux
Identification__hpux

IBM OS/400

TypeMacroFormatDescription
Identification__OS400__
Version__OS400_TGTVRM__VRMV = Version
R = Revision
M = Modification

illumos

TypeMacroDescription
Identification__illumos__See also: 13726 distinguish ourselves with a macro
IdentificationsunShared with Solaris; use not recommended
Identification__sunShared with Solaris; use not recommended

Note that illumos forked from Solaris in ~2010, but continues to provide the identifying definitions that Solaris provided at the point of the fork.

INTEGRITY

TypeMacro
Identification__INTEGRITY

Interix Environment

TypeMacroDescription
Identification__INTERIXDefined by GNU C and Visual C++

IRIX

TypeMacro
Identificationsgi
Identification__sgi

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

TypeMacroDescription
Identification__linux__1
IdentificationlinuxObsolete (not POSIX compliant)
Identification__linuxObsolete (not POSIX compliant)

LynxOS

TypeMacro
Identification__Lynx__

MacOS

TypeMacroDescription
IdentificationmacintoshMac OS 9
IdentificationMacintoshMac OS 9
Identification__APPLE__ && __MACH__Mac OS X

Defined by GNU C and Intel C++

Microware OS-9

TypeMacroDescription
Identification__OS9000Defined by Ultimate C/C++
Identification_OSKDefined by Ultimate C/C++

MidnightBSD

TypeMacroDescription
Identification__MidnightBSD__
Identification__MidnightBSD_kernel__
VersionBSD
Version__MidnightBSD_versionMust be included from <sys/param.h>

MINIX

TypeMacro
Identification__minix

MiNT

Originally MiNT is Not TOS, later renamed to MiNT is Now TOS.

TypeMacro
Identification__MINT__

MorphOS

TypeMacro
Identification__MORPHOS__

MPE/iX

TypeMacro
Identificationmpeix
Identification__mpexl

MSDOS

TypeMacro
IdentificationMSDOS
Identification__MSDOS__
Identification_MSDOS
Identification__DOS__

MSX

TypeMacroFormatDescription
Identification__MSXDefined by Z88DK
IdentificationMSXDefined by Z88DK

Native Client

TypeMacro
Identification__native_client__

NetBSD

TypeMacroFormatDescription
Identification__NetBSD__
VersionBSD
VersionNetBSD'V'_'R'V = Version
R = Revision

Must be included from <sys/param.h>
Version__NetBSD_Version__VVRRAAPP00VV = Version
RR = Revision
AA = Release
PP = Patch

From NetBSD 1.2D (?) until NetBSD 2.0H

Must be included from <sys/param.h>
Version__NetBSD_Version__VVRR00PP00VV = Version
RR = Revision
PP = Patch

From NetBSD 2.99.9

Must be included from <sys/param.h>
Example
NetBSD__NetBSD_Version__Macro
0.8NetBSD0_8
0.9NetBSD0_9
1.0NetBSD1_0 = 1
1.0ANetBSD1_0 = 2
1.2D102040000
1.2.1102000100

NeXTSTEP

TypeMacro
IdentificationNeXT

NonStop

TypeMacro
Identification__TANDEM

Nucleus RTOS

TypeMacro
Identification__nucleus__

OpenBSD

TypeMacroFormatDescription
Identification__OpenBSD__
VersionBSD
VersionOpenBSD'V'_'R'V = Version
R = Revision

Must be included from <sys/param.h>
Example
OpenBSDMacro
3.1OpenBSD3_1
3.9OpenBSD3_9

OS/2

TypeMacro
IdentificationOS2
Identification_OS2
Identification__OS2__
Identification__TOS_OS2__

Palm OS

TypeMacroDescription
Identification__palmos__Defined by GNU C in PRC-Tools

Plan 9

TypeMacro
IdentificationEPLAN9

Pyramid DC/OSx

TypeMacro
Identificationpyr

QNX

TypeMacroFormatDescription
Identification__QNX__QNX 4.x, 7.x, 8.x
Identification__QNXNTO__QNX 6.x
Version_NTO_VERSIONVRRV = Version
RR = Revision

Only available when __QNXNTO__ is defined.

Must be included from <sys/neutrino.h>
VersionBBNDK_VERSION_CURRENTVVRRRRPPPPV = Version
RRRR = Revision
PPPP = Patch

Only available on Blackberry 10

From Blackberry 10.1.0

Must be included from <bbndk.h>
Example
QNX_NTO_VERSION
6.2620

Reliant UNIX

TypeMacro
Identificationsinux

SCO OpenServer

TypeMacroDescription
IdentificationM_I386Defined by GNU C
IdentificationM_XENIXDefined by GNU C
Identification_SCO_DS

SerenityOS

TypeMacroDescription
Identification__serenity__Defined by GNU C and Clang

Solaris

TypeMacroDescription
Identificationsun
Identification__sun
Version__'System'_'Version'System = uname -s
Version = uname -r
Any illegal character is replaced by an underscore.

Defined by Sun Studio

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
SolarisMacro
2.7__SunOS_5_7
8__SunOS_5_8

Stratus VOS

TypeMacroFormatDescription
Identification__VOS__
Version__VOS__VV = 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

TypeMacroDescription
Identification__sysv__
Identification__SVR4
Identification__svr4__
Identification_SYSTYPE_SVR4Defined on IRIX

Syllable

TypeMacro
Identification__SYLLABLE__

Symbian OS

TypeMacro
Identification__SYMBIAN32__

Tru64 (OSF/1)

TypeMacro
Identification__osf__
Identification__osf

Ultrix

TypeMacro
Identificationultrix
Identification__ultrix
Identification__ultrix__
Identificationunix & vax

UNICOS

TypeMacroFormatDescription
Identification_UNICOS
Version_UNICOSVV = Version

UNICOS/mp

TypeMacroDescription
Identification_CRAY
__crayx1

UNIX Environment

TypeMacro
Identification__unix__
Identification__unix

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

TypeMacro
Identificationsco
Identification_UNIXWARE7

U/Win Environment

TypeMacro
Identification_UWIN

VMS

TypeMacroFormatDescription
IdentificationVMS
Identification__VMS
Version__VMS_VERVVRREPPTTVV = Version
RR = Revision
E = Edit number
PP = Patch (01 = A, ... 26 = Z)
TT = Type (22 = official)
Example
VMS__VMS_VER
6.160100022
6.260200022
6.2-1I60210922

VxWorks

TypeMacroDescription
Identification__VXWORKS__Defined by GNU C and Diab (from ?)
Identification__vxworksDefined by GNU C and Diab (from ?)
Version_WRS_VXWORKS_MAJORVersion

Must be included from <version.h>
Version_WRS_VXWORKS_MINORRevision

Must be included from <version.h>
Version_WRS_VXWORKS_MAINTPatch/maintenance

Must be included from <version.h>
Mode__RTP__For real-time mode
Mode_WRS_KERNELFor kernel mode
Example
VxWorks_WRS_VXWORKS_MAJOR_WRS_VXWORKS_MINOR_WRS_VXWORKS_MAINT
6.2620

Windows

TypeMacroDescription
Identification_WIN16Defined for 16-bit environments 1
Identification_WIN32Defined for both 32-bit and 64-bit environments 1
Identification_WIN64Defined for 64-bit environments 1
Identification__WIN32__Defined by Borland C++
Identification__TOS_WIN__Defined by xlC
Identification__WINDOWS__Defined for 16-bit-environments by Watcom C/C++ 1

Windows CE

TypeMacroFormatDescription
Identification_WIN32_WCEDefined by Embedded Visual C++
Version_WIN32_WCEVRRV = Version
R = Revision
IdentificationWIN32_PLATFORM_'P'P = Platform
VersionWIN32_PLATFORM_'P'VP = Platform
V = Version
Example
Version_WIN32_WCE
2.01201
2.11211
3.0300
4.0400
4.1410
4.2420
5.0501
PlatformMacroValue
H/PC 2000WIN32_PLATFORM_HPC2000
H/PC Pro 2.11WIN32_PLATFORM_HPCPRO211
H/PC Pro 3.0WIN32_PLATFORM_HPCPRO300
Pocket PCWIN32_PLATFORM_PSPC1
Pocket PC 2002WIN32_PLATFORM_PSPC310
Windows Mobile 2003WIN32_PLATFORM_PSPC400
Smartphone 2002WIN32_PLATFORM_WFSP100

Wind/U Environment

TypeMacroFormatDescription
Identification_WINDU_SOURCE
Version_WINDU_SOURCE0xVVRRPPVV = Version
RR = Revision
PP = Patch
Example
Wind/U_WINDU_SOURCE
3.1.20x030102

MVS/ESA, OS/390 and z/OS

TypeMacroDescription
Identification__MVS__Host
Identification__HOS_MVS__Host
Identification__TOS_MVS__Target

VM/ESA and z/VM

TypeMacroDescription
Identification__VM__Host
Identification__HOS_VM__Host
Identification__TOS_VM__Target