Keil Logo

Technical Support

On-Line Manuals

Compiler User Guide

Preface Overview of the Compiler Getting Started with the Compiler Compiler Features Compiler Coding Practices Compiler Diagnostic Messages Using the Inline and Embedded Assemblers of the AR Compiler Command-line Options Language Extensions Compiler-specific Features Keywords and operators __align __ALIGNOF__ __alignof__ __asm __forceinline __global_reg __inline __int64 __INTADDR__ __irq __packed __pure __smc __softfp __svc __svc_indirect __svc_indirect_r7 __value_in_regs __weak __writeonly __declspec attributes __declspec(noinline) __declspec(noreturn) __declspec(nothrow) __declspec(notshared) __declspec(thread) Function attributes __attribute__((alias)) function attribute __attribute__((always_inline)) function attribute __attribute__((const)) function attribute __attribute__((deprecated)) function attribute __attribute__((destructor[(priority)])) function a __attribute__((format)) function attribute __attribute__((format_arg(string-index))) function __attribute__((malloc)) function attribute __attribute__((noinline)) function attribute __attribute__((no_instrument_function)) function a __attribute__((nomerge)) function attribute __attribute__((nonnull)) function attribute __attribute__((noreturn)) function attribute __attribute__((notailcall)) function attribute __attribute__((nothrow)) function attribute __attribute__((pcs("calling_convention"))) functio __attribute__((pure)) function attribute __attribute__((section("name"))) function attribut __attribute__((sentinel)) function attribute __attribute__((unused)) function attribute __attribute__((used)) function attribute __attribute__((visibility("visibility_type"))) fun __attribute__((warn_unused_result)) __attribute__((weak)) function attribute __attribute__((weakref("target"))) function attrib Type attributes __attribute__((bitband)) type attribute __attribute__((aligned)) type attribute __attribute__((packed)) type attribute Variable attributes __attribute__((alias)) variable attribute __attribute__((at(address))) variable attribute __attribute__((aligned)) variable attribute __attribute__((deprecated)) variable attribute __attribute__((noinline)) constant variable attrib __attribute__((packed)) variable attribute __attribute__((section("name"))) variable attribut __attribute__((unused)) variable attribute __attribute__((used)) variable attribute __attribute__((visibility("visibility_type"))) var __attribute__((weak)) variable attribute __attribute__((weakref("target"))) variable attrib __attribute__((zero_init)) variable attribute Pragmas #pragma anon_unions, #pragma no_anon_unions #pragma arm #pragma arm section [section_type_list] #pragma diag_default tag[,tag,...] #pragma diag_error tag[,tag,...] #pragma diag_remark tag[,tag,...] #pragma diag_suppress tag[,tag,...] #pragma diag_warning tag[, tag, ...] #pragma exceptions_unwind, #pragma no_exceptions_u #pragma GCC system_header #pragma hdrstop #pragma import symbol_name #pragma import(__use_full_stdio) #pragma import(__use_smaller_memcpy) #pragma inline, #pragma no_inline #pragma no_pch #pragma Onum #pragma once #pragma Ospace #pragma Otime #pragma pack(n) #pragma pop #pragma push #pragma softfp_linkage, #pragma no_softfp_linkage #pragma thumb #pragma unroll [(n)] #pragma unroll_completely #pragma weak symbol, #pragma weak symbol1 = symbol Instruction intrinsics __breakpoint intrinsic __cdp intrinsic __clrex intrinsic __clz intrinsic __current_pc intrinsic __current_sp intrinsic __disable_fiq intrinsic __disable_irq intrinsic __dmb intrinsic __dsb intrinsic __enable_fiq intrinsic __enable_irq intrinsic __fabs intrinsic __fabsf intrinsic __force_loads intrinsic __force_stores intrinsic __isb intrinsic __ldrex intrinsic __ldrexd intrinsic __ldrt intrinsic __memory_changed intrinsic __nop intrinsic __pld intrinsic __pli intrinsic __qadd intrinsic __qdbl intrinsic __qsub intrinsic __rbit intrinsic __rev intrinsic __return_address intrinsic __ror intrinsic __schedule_barrier intrinsic __semihost intrinsic __sev intrinsic __sqrt intrinsic __sqrtf intrinsic __ssat intrinsic __strex intrinsic __strexd intrinsic __strt intrinsic __swp intrinsic __usat intrinsic __wfe intrinsic __wfi intrinsic __yield intrinsic ARMv6 SIMD intrinsics ETSI basic operations C55x intrinsics VFP status intrinsic __vfp_status intrinsic Fused Multiply Add (FMA) intrinsics Named register variables GNU built-in functions Predefined macros Built-in function name variables C and C++ Implementation Details What is Semihosting? Via File Syntax Summary Table of GNU Language Extensions Standard C Implementation Definition Standard C++ Implementation Definition C and C++ Compiler Implementation Limits

Predefined macros

9.155 Predefined macros

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

The following table lists the macro names predefined by the ARM compiler for C and C++. Where the value field is empty, the symbol is only defined.

Table 9-21 Predefined macros

Name Value When defined
__arm__ -
Always defined for the ARM compiler, even when you specify the --thumb option.
See also __ARMCC_VERSION.
__ARMCC_VERSION ver
Always defined. It is a decimal number, and is guaranteed to increase between releases. The format is PVVbbbb where:
  • P is the major version
  • VV is the minor version
  • bbbb is the build number.

Note

Use this macro to distinguish between ARM Compiler 4.1 or later, and other tools that define __arm__.
__APCS_INTERWORK -
When you specify the --apcs /interwork option or set the target processor architecture to ARMv5T or later.
__APCS_ROPI -
When you specify the --apcs /ropi option.
__APCS_RWPI -
When you specify the --apcs /rwpi option.
__APCS_FPIC -
When you specify the --apcs /fpic option.
__ARRAY_OPERATORS - In C++ compiler mode, to specify that array new and delete are enabled.
__BASE_FILE__ name
Always defined. Similar to __FILE__, but indicates the primary source file rather than the current one (that is, when the current file is an included file).
__BIG_ENDIAN - If compiling for a big-endian target.
_BOOL -
In C++ compiler mode, to specify that bool is a keyword.
__cplusplus - In C++ compiler mode.
__CC_ARM 1
Always set to 1 for the ARM compiler, even when you specify the --thumb option.
__CHAR_UNSIGNED__ - In GNU mode. It is defined if and only if char is an unsigned type.
__DATE__ date Always defined.
__EDG__ -
Always defined.
__EDG_IMPLICIT_USING_STD -
In C++ mode when you specify the --using_std option.
__EDG_VERSION__ -
Always set to an integer value that represents the version number of the Edison Design Group (EDG) front-end. For example, version 3.8 is represented as 308.

Note

The version number of the EDG front-end does not necessarily match the version number of the ARM compiler toolchain.
__EXCEPTIONS 1
In C++ mode when you specify the --exceptions option.
__FEATURE_SIGNED_CHAR -
When you specify the --signed_chars option (used by CHAR_MIN and CHAR_MAX).
__FILE__ name Always defined as a string literal.
__FP_FAST -
When you specify the --fpmode=fast option.
__FP_FENV_EXCEPTIONS -
When you specify the --fpmode=ieee_full or --fpmode=ieee_fixed options.
__FP_FENV_ROUNDING -
When you specify the --fpmode=ieee_full option.
__FP_IEEE -
When you specify the --fpmode=ieee_full, --fpmode=ieee_fixed, or --fpmode=ieee_no_fenv options.
__FP_INEXACT_EXCEPTION -
When you specify the --fpmode=ieee_full option.
__GNUC__ ver
When you specify the --gnu option. It is an integer that shows the current major version of the GNU mode being used.
__GNUC_MINOR__ ver
When you specify the --gnu option. It is an integer that shows the current minor version of the GNU mode being used.
__GNUG__ ver In GNU mode when you specify the --cpp option. It has the same value as __GNUC__.
__IMPLICIT_INCLUDE -
When you specify the --implicit_include option.
__INTMAX_TYPE__ - In GNU mode. It defines the correct underlying type for the intmax_t typedef.
__LINE__ num Always set. It is the source line number of the line of code containing this macro.
__MODULE__ mod
Contains the filename part of the value of __FILE__.
__MULTIFILE - When you explicitly or implicitly use the --multifile option.a
__NO_INLINE__ -
When you specify the --no_inline option in GNU mode.
__OPTIMISE_LEVEL num
Always set to 2 by default, unless you change the optimization level using the -Onum option.a
__OPTIMISE_SPACE -
When you specify the -Ospace option.
__OPTIMISE_TIME -
When you specify the -Otime option.
__OPTIMIZE__ -
When -O1, -O2, or -O3 is specified in GNU mode.
__OPTIMIZE_SIZE__ -
When -Ospace is specified in GNU mode.
__PLACEMENT_DELETE - In C++ mode to specify that placement delete (that is, an operator delete corresponding to a placement operator new, to be called if the constructor throws an exception) is enabled. This is only relevant when using exceptions.
__PTRDIFF_TYPE__ - In GNU mode. It defines the correct underlying type for the ptrdiff_t typedef.
__RTTI - In C++ mode when RTTI is enabled.
__sizeof_int 4
For sizeof(int), but available in preprocessor expressions.
__sizeof_long 4
For sizeof(long), but available in preprocessor expressions.
__sizeof_ptr 4
For sizeof(void *), but available in preprocessor expressions.
__SIZE_TYPE__ - In GNU mode. It defines the correct underlying type for the size_t typedef.
__SOFTFP__ -
If compiling to use the software floating-point calling standard and library. Set when you specify the --fpu=softvfp option for ARM or Thumb, or when you specify --fpu=softvfp+vfpv2 for Thumb.
__STDC__ - In all compiler modes.
__STDC_VERSION__ - Standard version information.
__STRICT_ANSI__ -
When you specify the --strict option.
__SUPPORT_SNAN__ - Support for signaling NaNs when you specify --fpmode=ieee_fixed or --fpmode=ieee_full.
__TARGET_ARCH_ARM num The number of the ARM base architecture of the target processor irrespective of whether the compiler is compiling for ARM or Thumb. For possible values of __TARGET_ARCH_ARM in relation to the ARM architecture versions, see the table below.
__TARGET_ARCH_THUMB num
The number of the Thumb base architecture of the target processor irrespective of whether the compiler is compiling for ARM or Thumb. The value is defined as zero if the target does not support Thumb. For possible values of __TARGET_ARCH_THUMB in relation to the ARM architecture versions, see the table below.
__TARGET_ARCH_XX -
XX represents the target architecture and its value depends on the target architecture. For example, if you specify the compiler options --cpu=4T or --cpu=ARM7TDMI then __TARGET_ARCH_4T is defined.
__TARGET_CPU_XX -
XX represents the target processor. The value of XX is derived from the --cpu compiler option, or the default if none is specified. For example, if you specify the compiler option --cpu=ARM7TDMI then __TARGET_CPU_ARM7TDMI is defined and no other symbol starting with __TARGET_CPU_ is defined.
If you specify the target architecture, then __TARGET_CPU_generic is defined.
If the processor name specified with --cpu is in lowercase, it is converted to uppercase. For example, --cpu=Cortex-R4 results in __TARGET_CPU_CORTEX_R4 being defined (rather than __TARGET_CPU_Cortex_R4).
If the processor name contains hyphen (-) characters, these are mapped to an underscore (_). For example, --cpu=ARM1136JF-S is mapped to __TARGET_CPU_ARM1136JF_S.
__TARGET_FEATURE_DIVIDE -
If the target architecture supports the hardware divide instruction (that is, ARMv7-M or ARMv7-R).
__TARGET_FEATURE_DOUBLEWORD -
ARMv5T and above.
__TARGET_FEATURE_DSPMUL - If the DSP-enhanced multiplier is available, for example ARMv5TE.
__TARGET_FEATURE_EXTENSION_REGISTER_COUNT num
The number of 64-bit extension registers available in NEON or VFP.
__TARGET_FEATURE_MULTIPLY -
If the target architecture supports the long multiply instructions MULL and MULAL.
__TARGET_FEATURE_THUMB - If the target architecture supports Thumb, ARMv4T or later.
__TARGET_FPU_xx -
One of the following is set to indicate the FPU usage:
  • __TARGET_FPU_NONE
  • __TARGET_FPU_VFP
  • __TARGET_FPU_SOFTVFP
In addition, if compiling with one of the following --fpu options, the corresponding target name is set:
  • --fpu=softvfp+vfpv2, __TARGET_FPU_SOFTVFP_VFPV2
  • --fpu=softvfp+vfpv3, __TARGET_FPU_SOFTVFP_VFPV3
  • --fpu=softvfp+vfpv3_fp16, __TARGET_FPU_SOFTVFP_VFPV3_FP16
  • --fpu=softvfp+vfpv3_d16, __TARGET_FPU_SOFTVFP_VFPV3_D16
  • --fpu=softvfp+vfpv3_d16_fp16, __TARGET_FPU_SOFTVFP_VFPV3_D16_FP16
  • --fpu=softvfp+vfpv4, __TARGET_FPU_SOFTVFP_VFPV4
  • --fpu=softvfp+vfpv4_d16, __TARGET_FPU_SOFTVFP_VFPV4_D16
  • --fpu=softvfp+fpv4-sp, __TARGET_FPU_SOFTVFP_FPV4_SP
  • --fpu=vfp, __TARGET_FPU_VFPV2
  • --fpu=vfpv2, __TARGET_FPU_VFPV2
  • --fpu=vfpv3, __TARGET_FPU_VFPV3
  • --fpu=vfpv3_fp16, __TARGET_FPU_VFPV3_FP16
  • --fpu=vfpv3_d16, __TARGET_FPU_VFPV3_D16
  • --fpu=vfpv3_d16_fp16, __TARGET_FPU_VFPV3_D16_FP16
  • --fpu=vfpv4, __TARGET_FPU_VFPV4
  • --fpu=vfpv4_d16, __TARGET_FPU_VFPV4_D16
  • --fpu=fpv4-sp, __TARGET_FPU_FPV4_SP
__TARGET_PROFILE_R - When you specify the --cpu=7-R option.
__TARGET_PROFILE_M -
When you specify any of the following options:
  • --cpu=6-M
  • --cpu=6S-M
  • --cpu=7-M
__thumb__ -
When the compiler is in Thumb state. That is, you have either specified the --thumb option on the command-line or #pragma thumb in your source code.

Note

  • The compiler might generate some ARM code even if it is compiling for Thumb.
  • __thumb and __thumb__ become defined or undefined when using #pragma thumb or #pragma arm, but do not change in cases where Thumb functions are generated as ARM code for other reasons (for example, a function specified as __irq).
__TIME__ time
Always defined.
__UINTMAX_TYPE__ - In GNU mode. It defines the correct underlying type for the uintmax_t typedef.
__USER_LABEL_PREFIX__ - In GNU mode. It defines an empty string.
__VERSION__ ver
When you specify the --gnu option. It is a string that shows the current version of the GNU mode being used.
_WCHAR_T -
In C++ mode, to specify that wchar_t is a keyword.
__WCHAR_TYPE__ - In GNU mode. It defines the correct underlying type for the wchar_t typedef.
__WCHAR_UNSIGNED__ - In GNU mode when you specify the --cpp option. It is defined if and only if wchar_t is an unsigned type.
__WINT_TYPE__ - In GNU mode. It defines the correct underlying type for the wint_t typedef.
The following table shows the possible values for __TARGET_ARCH_THUMB, and how these values relate to versions of the ARM architecture.

Table 9-22 Thumb architecture versions in relation to ARM architecture versions

ARM architecture __TARGET_ARCH_ARM __TARGET_ARCH_THUMB
v4 4 0
v4T 4 1
v5T, v5TE, v5TEJ 5 2
v6, v6K, v6Z 6 3
v6T2 6 4
v6-M, v6S-M 0 3
v7-R 7 4
v7-M, v7E-M 0 4
a 
ARM recommends that if you have source code reliant on the __OPTIMISE_LEVEL macro to determine whether or not --multifile is in effect, you change to using__MULTIFILE.
Non-ConfidentialPDF file icon PDF versionARM DUI0375H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.