You copied the Doc URL to your clipboard.

Predefined macros

The ARM® compiler predefines a number of macros. These macros provide information about toolchain version numbers and compiler options.

Note

This topic includes descriptions of [BETA] features.

In general, the predefined macros generated by the compiler are compatible with those generated by GCC. See the GCC documentation for more information.

The following table lists ARM-specific macro names predefined by the ARM compiler for C and C++, together with a number of the most commonly used macro names. Where the value field is empty, the symbol is only defined.

Note

Use armclang --target=triple -E -dM file to see the values of predefined macros.

Macros beginning with __ARM_ are defined by the ARM C Language Extensions 2.0 (ACLE 2.0).

Note

armclang does not fully implement ACLE 2.0.

Table 5-1 Predefined macros

Name Value When defined
__APCS_FPIC 1

Set when you specify the -fbare-metal-pie option.

__APCS_ROPI 1

Set when you specify the -fropi option.

__APCS_RWPI 1

Set when you specify the -frwpi option.

__ARM_64BIT_STATE 1

Set for 64-bit targets only.

Set to 1 if code is for 64-bit state.

__ARM_ALIGN_MAX_STACK_PWR 4

Set for 64-bit targets only.

The log of the maximum alignment of the stack object.

__ARM_ARCH ver

Specifies the version of the target architecture, for example 8.

__ARM_ARCH_EXT_IDIV__ 1

Set for 32-bit targets only.

Set to 1 if hardware divide instructions are available.

__ARM_ARCH_ISA_A64 1

Set for 64-bit targets only.

Set to 1 if the target supports the A64 instruction set.

__ARM_ARCH_PROFILE ver

Specifies the profile of the target architecture, for example 'A'.

__ARM_BIG_ENDIAN - Set if compiling for a big-endian target.
__ARM_FEATURE_CLZ 1

Set to 1 if the CLZ (count leading zeroes) instruction is supported in hardware.

__ARM_FEATURE_CMSE num

Indicates the availability of the ARMv8-M Security Extensions related extensions:

0
The ARMv8-M TT instruction is not available.
1
The TT instruction is available. It is not part of ARMv8-M Security Extensions, but is closely related.
3
The ARMv8-M Security Extensions for secure executable files is available. This implies that the TT instruction is available.

See  TT instruction intrinsics [BETA] for more information.

__ARM_FEATURE_CRC32 1

Set to 1 if the target has CRC extension.

__ARM_FEATURE_CRYPTO 1

Set to 1 if the target has cryptographic extension.

__ARM_FEATURE_DIRECTED_ROUNDING 1 Set to 1 if the directed rounding and conversion vector instructions are supported.

Only available when __ARM_ARCH >= 8.

__ARM_FEATURE_DIV 1

Set for 64-bit targets only.

Set to 1 if the target supports fused floating-point multiply-accumulate.

__ARM_FEATURE_DSP 1

Set for 32-bit targets only.

Set to 1 if DSP instructions are supported. This feature also implies support for the Q flag.

Note

This macro is deprecated in ACLE 2.0 for A-profile. It is fully supported for M and R-profiles.
__ARM_FEATURE_FMA 1

Set to 1 if the target supports fused floating-point multiply-accumulate.

__ARM_FEATURE_NUMERIC_MAXMIN 1

Set to 1 if the target supports floating-point maximum and minimum instructions.

Only available when __ARM_ARCH >= 8.

__ARM_FEATURE_QBIT 1

Set for 32-bit targets only.

Set to 1 if the Q (saturation) flag exists.

Note

This macro is deprecated in ACLE 2.0 for A-profile.
__ARM_FEATURE_SAT 1

Set for 32-bit targets only.

Set to 1 if the SSAT and USAT instructions are supported. This feature also implies support for the Q flag.

Note

This macro is deprecated in ACLE 2.0 for A-profile.
__ARM_FEATURE_SIMD32 1

Set for 32-bit targets only.

Set to 1 if the target supports 32-bit SIMD instructions.

Note

This macro is deprecated in ACLE 2.0 for A-profile, use NEON intrinsics instead.
__ARM_FEATURE_UNALIGNED 1

Set to 1 if the target supports unaligned access in hardware.

__ARM_FP val

Set if hardware floating-point is available.

Permitted values include:

  • 0x2 for half-support
  • 0x4 for single-support
  • 0x8 for double-support
__ARM_FP_FAST 1

Set for 64-bit targets only.

Set if -ffast-math is specified.

__ARM_FP_FENV_ROUNDING 1

Set for 64-bit targets only.

Set to 1 if the implementation allows rounding to be configured at runtime using the standard C fesetround() function.

__ARM_NEON -

Defined when the compiler is targeting an architecture or processor with Advanced SIMD available.

Use this macro to conditionally include arm_neon.h, to permit the use of Advanced SIMD intrinsics.

__ARM_NEON_FP 7

Set when Advanced SIMD floating-point vector instructions are available.

__ARM_PCS 1

Set for 32-bit targets only.

Set to 1 if the default procedure calling standard for the translation unit conforms to the base PCS.

__ARM_PCS_VFP 1

Set for 32-bit targets only.

Set to 1 if -mfloat-abi=hard.

__ARM_SIZEOF_MINIMAL_ENUM value

Specifies the size of the minimal enumeration type. Set to either 1 or 4 depending on whether -fshort-enums is specified or not.

__ARM_SIZEOF_WCHAR_T value

Specifies the size of wchar in bytes.

Set to 2 if -fshort-wchar is specified, or 4 if -fno-short-wchar is specified.

Note

The default size is 4, because -fno-short-wchar is set by default.
__ARMCOMPILER_VERSION nnnbbbb

Always set. Specifies the version number of the compiler, armclang.

The format is Mmmuuxx, where:

  • M is the major version number, 6.
  • mm is the minor version number.
  • uu is the update number.
  • xx is reserved for ARM internal use. You can ignore this for the purposes of checking whether the current release is a specific version or within a range of versions.

For example, version 6.2 update 1 is displayed as 6020154, where 54 is a number for ARM internal use.

__ARMCC_VERSION nnnbbbb

A synonym for __ARMCOMPILER_VERSION.

__arm__ 1

Defined when targeting the A32 or T32 instruction sets with AArch32 targets, for example --target=arm-arm-none-eabi.

See also __aarch64__.

__aarch64__ 1

Defined when targeting the A64 instruction set with --target=aarch64-arm-none-eabi.

See also __arm__.

__cplusplus ver

Defined when compiling C++ code, and set to a value that identifies the targeted C++ standard. For example, when compiling with -xc++ -std=gnu++98, the compiler sets this macro to 199711L.

You can use the __cplusplus macro to test whether a file was compiled by a C compiler or a C++ compiler.

__CHAR_UNSIGNED__ 1 Defined if and only if char is an unsigned type.
__EXCEPTIONS 1

Defined when compiling a C++ source file with exceptions enabled.

__GNUC__ ver

Always set. It is an integer that shows the current major version of the compatible GCC version.

__GNUC_MINOR__ ver

Always set. It is an integer that shows the current minor version of the compatible GCC version.

__INTMAX_TYPE__ type Always set. Defines the correct underlying type for the intmax_t typedef.
__NO_INLINE__ 1

Defined if no functions have been inlined. The macro is always defined with optimization level -O0 or if the -fno-inline option is specified.

__OPTIMIZE__ 1

Defined when -O1, -O2, -O3, -Ofast, -Oz, or -Os is specified.

__OPTIMIZE_SIZE__ 1

Defined when -Os or -Oz is specified.

__PTRDIFF_TYPE__ type Always set. Defines the correct underlying type for the ptrdiff_t typedef.
__SIZE_TYPE__ type Always set. Defines the correct underlying type for the size_t typedef.
__SOFTFP__ 1

Set for 32-bit targets only.

Set to 0 otherwise.

__STDC__ 1 Always set. Signifies that the compiler conforms to ISO Standard C.
__STRICT_ANSI__ 1

Defined if you specify the --ansi option or specify one of the --std=c* options .

__thumb__ 1

Defined if you specify the -mthumb option.

__UINTMAX_TYPE__ type Always set. Defines the correct underlying type for the uintmax_t typedef.
__VERSION__ ver

Always set. A string that shows the underlying Clang version.

__WCHAR_TYPE__ type Always set. Defines the correct underlying type for the wchar_t typedef.
__WINT_TYPE__ type Always set. Defines the correct underlying type for the wint_t typedef.
Was this page helpful? Yes No