22.4 Predefined Macros

The compiler provides a number of macro definitions that characterize the various target-specific options and other aspects of the compiler and host environment. Some of these are listed in the table below.

See also the device-specific include files (pic32c/include/proc/family/device.h) for other macros that can be used to determine the features available on the selected device. You will find these macros near the end of the header file.

You can also run the compiler with the -E and -dM options to have it print out those macros defined for that particular project and set of compiler options.

Table 22-2. Predefined Macro Definitions
Macro Meaning
__PIC32C

__PIC32C__

Defined when a PIC32CX device is specified with the -mprocessor option. Always defined when targeting a PIC32C/SAM device.
__PIC32CZ Defined when a PIC32CZ device is specified with the -mprocessor option.
__LANGUAGE_ASSEMBLY

__LANGUAGE_ASSEMBLY__

_LANGUAGE_ASSEMBLY

Defined if compiling a pre-processed assembly file (.S files).
LANGUAGE_ASSEMBLY Defined if compiling a pre-processed assembly file (.S files) and -ansi is not specified.
__LANGUAGE_C

__LANGUAGE_C__

_LANGUAGE_C

Defined if compiling a C file.
LANGUAGE_C Defined if compiling a C file and -ansi is not specified.
__LANGUAGE_C_PLUS_PLUS

__cplusplus

_LANGUAGE_C_PLUS_PLUS__

Defined if compiling a C++ file.
__EXCEPTIONS Defined if C++ exceptions are enabled.
__GXX_RTTI Defined if runtime type information is enabled.
__PROCESSOR__ Where
PROCESSOR
is the capitalized argument to the -mprocessor option. For example, when using -mprocessor=32CX0525SG12144, the compiler will define __32CX05255SG12144__.
__XC Always defined to indicate that this is a Microchip XC compiler.
__XC32 Always defined to indicate this the XC32 compiler.
__VERSION__ The __VERSION__ macro expands to a string constant describing the compiler in use. Do not rely on its contents having any particular form, but it should contain at least the release number. Use the __XC32_VERSION macro for a numeric version number.
__XC32_VERSION or __C32_VERSION__ The C compiler defines the constant __XC32_VERSION, giving a numeric value to the version identifier. This macro can be used to construct applications that take advantage of new compiler features while still remaining backward compatible with older versions. The value is based upon the major and minor version numbers of the current release. For example, release version 1.03 will have a __XC32_VERSION definition of 1030. This macro can be used, in conjunction with standard preprocessor comparison statements, to conditionally include/exclude various code constructs.
__arm__ Defined when compiling for ARM architectures, regardless of whether generating Thumb or ARM code.
__thumb__ Defined to indicate the compiler is generating Thumb code. This definition is subject to the -mthumb and -marm options.
__thumb2__ Defined when generating Thumb code for a target processor supporting the Thumb-2 instruction set.
__SOFTFP__ Defined when compiling for software floating-point, i.e. when -mfloat-abi=soft is in effect.
__ARM_FP Defined to an integer mask describing the floating-point capability of the current target processor. This is 0 when software floating point is in effect. Otherwise, bits 1, 2 and 3 of the mask are set to indicate support for 16, 32 and 64-bit hardware floating point, respectively.
__XC32_DTCM_LENGTH Defined to be the size (in bytes) of the data tightly coupled memory specified by the -mdtcm option.
__XC32_ITCM_LENGTH Defined to be the size (in bytes) of the instruction tightly coupled memory specified by the -mitcm option.
__XC32_TCM_LENGTH Defined to be the size (in bytes) of the combined tightly coupled memory specified by the -mtcm option.