3.4. Predefined macros

Table 3.3 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 3.3. Predefined macros

NameValueWhen defined
__arm__

Always defined for the ARM compiler, even when you specify the --thumb option.

See also __ARMCC_VERSION.

Note

These macros are also defined if you invoke the ARM compiler using the commands, armcpp, tcc, and tcpp.

__ARMCC_VERSIONver

Always defined. It is a decimal number, and is guaranteed to increase between releases. The format is PVtbbb where:

  • P is the major version

  • V is the minor version

  • t is the patch release

  • bbb is the build number.

See Table 3.4 for values in current release.

Note

Use this to distinguish between RVCT and other tools that define __arm__.

__APCS_ADSABI

When you specify the --apcs /adsabi option.

__APCS_INTERWORK

When you specify the --apcs /interwork option or set the CPU architecture to ARMv5TE 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_OPERATORSIn 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_ENDIANIf compiling for a big-endian target.
_BOOL

In C++ compiler mode, to specify that bool is a keyword.

__cplusplusIn C++ compiler mode.
__CC_ARM1

Always set to 1 for the ARM compiler, even when you specify the --thumb option.

Note

This macro is also defined if you invoke the ARM compiler using armcpp, tcc, and tcpp.

__DATE__dateAlways defined.
__EDG__

Always defined.

__EDG_IMPLICIT_USING_STD

In C++ compiler mode when you specify the --implicit_using_std option.

__EDG_VERSION__

Always set to an integer value that represents the version number of the EDG front end. For example, version 36 is represented as 306.

The version number of the EDG front-end does not necessarily match the RVCT or RVDS version number.

__EXCEPTIONS1

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__nameAlways 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.

See Table 3.4 for value in current release.

__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.

See Table 3.4 for value in current release.

__IMPLICIT_INCLUDE

When you specify the --implicit_include option.

__LINE__numAlways 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__.

__NO_INLINE__

When you specify the --no_inline option in GNU mode.

__OPTIMISE_LEVELnum

Always set to 2 by default, unless you change the optimization level using the -Onum option.

__OPTIMISE_SPACE

When you specify the -Ospace option.

__OPTIMISE_TIME

When you specify the -Otime option.

__OPTIMIZE__

When -O1 or -O2 (the default) is specified in GNU mode.

__OPTIMIZE_SIZE__

When -Ospace (the default) is specified in GNU mode.

__PLACEMENT_DELETEIn C++ compiler mode to specify that placement delete is enabled. This is only relevant when using exceptions.
__RTTIIn C++ compiler mode when RTTI is enabled.
__sizeof_int4

For sizeof(int), but available in preprocessor expressions.

__sizeof_long4

For sizeof(long), but available in preprocessor expressions.

__sizeof_ptr4

For sizeof(void *), but available in preprocessor expressions.

__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.

__TARGET_ARCH_ARMnumThe number of the ARM base architecture of the target CPU (irrespective of whether the compiler is compiling for ARM or Thumb).
__TARGET_ARCH_THUMBnumThe number of the Thumb base architecture of the target CPU (irrespective of whether the compiler is compiling for ARM or Thumb). The value is defined as zero if the target does not support Thumb.
__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 cpu. 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 ARM7TM then __TARGET_CPU_ARM7TM 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 contains hyphen (-) characters, these are mapped to an underscore (_). For example, --cpu ARM1136JF-S is mapped to __TARGET_CPU_ARM1136JF_S.

__TARGET_FEATURE_DOUBLEWORD

If the target architecture supports the PLD, LDRD, STRD, MCRR, and MRRC instructions. That is, ARMv5T and above.

__TARGET_FEATURE_DSPMULIf the DSP-enhanced multiplier is available, for example ARMv5TE.
__TARGET_FEATURE_MULTIPLY

If the target architecture supports the long multiply instructions MULL and MULAL.

__TARGET_FEATURE_DIVIDE

If the target architecture supports the hardware divide instruction (that is, ARMv7-M or ARMv7-R).

__TARGET_FEATURE_THUMBIf 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 --fpu softvfp+vfpv2 or --fpu softvfp+vfpv3, __TARGET_FPU_SOFTVFP_VFPV2 or __TARGET_FPU_SOFTVFP_VFPV3 is also set.

See the description of the --fpu vfp option in Specifying the target processor or architecture for more information on FPU options.

__thumb__

When the compiler is in Thumb mode. 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 for other reasons (for example, a function specified as __irq).

__TIME__time

Always defined.

__VERSION__ver

When you specify the --gnu option. It is a string that shows the current version of the GNU mode being used.

See Table 3.4 for value in current release.

_WCHAR_T

In C++ compiler mode, to specify that wchar_t is a keyword.

Table 3.4 lists the values of predefined macros in the current release of the compiler. These values might change if you upgrade your installation.

Table 3.4. Macro values in current release

NameValue
__ARMCC_VERSION

Guaranteed to increase between releases, the format is PVtbbb where:

  • P = 3

  • V = 0

  • t = 0 (unpatched)

  • bbb = the build number, for example, 503.

The example given results in 300503.

__GNUC__

Major version of the GNU mode = 3.

__GNUC_MINOR__

Minor version of the GNU mode = 3.

__VERSION__

Current version of the GNU mode = “EDG gcc 3.3 mode”.

Where you specify macro command-line options, the compiler defines and undefines macros in the following order:

  1. Compiler predefined macros.

  2. Macros defined explicitly, using -Dname.

  3. Macros explicitly undefined, using -Uname.

See Setting preprocessor options for details.

Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0205G
Non-Confidential