Content
    Preprocessor Defines

Preprocessor Defines

Preprocessor Defines

This page lists commonly used preprocessor defines for C/C++

Programming Language

LanguageDefine
C++__cplusplus
C 99__STDC__

Compiler

CompilerDefine
GNU__GNUC__
Visual Studio_MSC_VER_

Processor

ProcessorDefines
x86_M_IX86, __INTEL__, __i386__
x86-64_M_X64, __x86_64__
IA64_IA64__

Endianness

| Byte Order | Define | |-----------------|--- -----------------| | Little Endian | __LITTLE_ENDIAN__ | | Big Endian | __BIG_ENDIAN__ |

OS

OSDefines
Windows 32 bit_WIN32, __WINDOWS__
Windows 64 bit_WIN64, _WIN32
Linux 32 bit__unix__, __linux__
Linux 64 bit__unix__, __linux__, __LP64__
BSD__unix__, __BSD__, __FREEBSD__
OS X__APPLE__, __DARWIN__, __MACH__

Debugging

PurposeDefines
Visual Studio Debug Code_DEBUG
Disable assert()NDEBUG

Qt

Qt has it’s own preprocessor defines: Global Qt Declarations

Endianness

Byte OrderDefine
Little EndianQ_LITTLE_ENDIAN
Big EndianQ_BIG_ENDIAN

Q_BYTE_ORDER is set to either Q_LITTLE_ENDIAN or Q_BIG_ENDIAN.

Compiler

CompilerDefine
GNU C++ (and clang?)Q_CC_GNU
Microsoft Visual C/C++ or Intel C++ for WindowsQ_CC_MSVC
Intel C++ (Linux, Windows)Q_CC_INTEL

There are a lot more defines for different compilers.

OS

OSDefine
AndroidQ_OS_ANDROID
BSD 4.4Q_OS_BSD4
CygwinQ_OS_CYGWIN
OS X, iOS, DarwinQ_OS_DARWIN
FreeBSDQ_OS_FREEBSD
iOSQ_OS_IOS
LinuxQ_OS_LINUX
OS X, iOS (not OSS Darwin)Q_OS_MAC
NetDSBQ_OS_NETBSD
OpenDSBQ_OS_OPENBSD
OS XQ_OS_OSX
QNX NeutrinoQ_OS_QNX
Any UNIX BSD/SYSV systemQ_OS_UNIX
32-bit and 64-bit Windows (not Windows CE)Q_OS_WIN32
64-bit WindowsQ_OS_WIN64
All supported WindowsQ_OS_WIN
Windows CEQ_OS_WINCE
Windows Phone 8Q_OS_WINPHONE
Windows RuntimeQ_OS_WINRT

There are a lot more defines for supported OS’s by Qt.

Processors

ProcessorDefines
Intel x86 (32-bit, 64-bit)Q_PROCESSOR_X86
Intel x86 (32-bit)Q_PROCESSOR_X86_32
Intel x86 (64-bit)Q_PROCESSOR_X86_64
Inel IA64 (Itanium, Itanium 2)Q_PROCESSOR_IA64
ARM (V5, V6, V7)Q_PROCESSOR_ARM (defined on all ARM architectures)
ARMv5Q_PROCESSOR_ARM_V5
ARMv6Q_PROCESSOR_ARM_V6, Q_PROCESSOR_ARM_V5
ARMv7Q_QPROCESSOR_ARM_V7.Q_PROCESSOR_ARM_V6, Q_PROCESSOR_ARM_V5
AVR 32Q_PROCESSOR_AVR32

There are a lot more defines for supported processors by Qt.



  • Category

  • Programming

  • Tags

  • C
    C++

  • Created

  • 11. August 2015


  • Modified

  • 17. March 2022