Skip to content

Compiler internal symbols

Felipe Torrezan edited this page Aug 28, 2023 · 1 revision

Each compiler will have its own set of compiler specific symbols which may be used to write code that is only compiled by a specific toolchain, or even version of a toolchain.

The compiler specific predefined symbols for the GNU compiler (GCC) are listed below along with the equivalent/counterpart symbols for the IAR C/C++ Compiler.

Symbols

GCC IAR Description
__CHAR_BIT__ __CHAR_BITS__ Size of char in bits
__SCHAR_MAX__ __CHAR_MAX__ Maximum value a signed char can receive
__INT_MAX__ __SIGNED_INT_MAX__ 2147483647 (32-bit target)
__INT8_MAX__ __INT8_T_MAX__ 127
__INT8_TYPE__ __INT8_T_TYPE__ signed char
__INT16_MAX__ __INT16_T_MAX__ 32767
__INT16_TYPE__ __INT16_T_TYPE__ signed short int
__INT32_MAX__ __INT32_T_MAX__ 2147483647
__INT32_TYPE__ __INT32_T_TYPE__ signed int
__INT64_MAX__ __INT64_T_MAX__ 9223372036854775807LL
__INT64_TYPE__ __INT64_T_TYPE__ signed long long int
__UINT_MAX__ __UNSIGNED_INT_MAX__ 0xffffffffU (32-bit target)
__UINT8_MAX__ __UINT8_T_MAX__ 0xff
__UINT8_TYPE__ __UINT8_T_TYPE__ unsigned char
__UINT16_MAX__ __UINT16_T_MAX__ 0xffff
__UINT16_TYPE__ __UINT16_T_TYPE__ unsigned short int
__UINT32_MAX__ __UINT32_T_MAX__ 0xffffffffU
__UINT32_TYPE__ __UINT32_T_TYPE__ unsigned int
__UINT64_MAX__ __UINT64_T_MAX__ 0xffffffffffffffffU
__UINT64_TYPE__ __UINT64_T_TYPE__ unsigned long long int
__SIZEOF_SHORT__ #define __SIZEOF_SHORT__ N Size of short in bytes
__SIZEOF_INT__ #define __SIZEOF_INT__ N Size of int in bytes
__SIZEOF_LONG}__ #define __SIZEOF_LONG__ N Size of long in bytes
__INTPTR_MAX__ __INTPTR_T_MAX__
__INTPTR_TYPE__ __INTPTR_T_TYPE__
__INTPTR_WIDTH__ #define __INTPTR_WIDTH__ N Size of a int * in bits
__SIZEOF_POINTER__ __DEF_PTR_SIZE__ Size of int * in bytes
__DIFFPTR_MAX__ __INTPTR_T_MAX__
__DIFFPTR_WIDTH__ #define __DIFFPTR_WIDTH__ N Size of ptrdiff_t * in bits
__SIZEOF_PTRDIFF_T__ __DEF_PTR_SIZE__ Size of ptrdiff_t * in bytes
__SIZE_TYPE__ __SIZE_T_TYPE__ Type of size_t
__SIZE_MAX__ __SIZE_T_MAX__ Size of size_t in bytes
__GNUC_MINOR__,
__GNUC_PATCHLEVEL__
__BUILD_NUMBER__ IAR provides a single symbol which lumps all necessary data
ARM_ARCH_*__ __CORE__ Architecture variant based on target selection (*Arm only)
__VFP_FP__ __ARMVFP__ VFP usage (*Arm only)
__GNUC__ __IAR_SYSTEMS_ICC__ Can be used to detect the compiler toolchain
__arm__ __ICCARM__ Denotes "build for Arm target" (*Arm only)
__IEEE_LITTLE_ENDIAN__
__IEEE_BIG_ENDIAN__
__LITTLE_ENDIAN__ Endian setting
__VERSION__ __VER__ String representation of compiler version "MAJOR.MINOR.PATCH"