4.13.2 Predefined Macros

The compiler drivers define certain symbols to the preprocessor, allowing conditional compilation based on chip type, etc. The symbols tabulated below show the more common symbols defined by the drivers. Each symbol, if defined, is equated to 1 (unless otherwise stated).

Table 4-15. Predefined Macros
Symbol Description
__AVR_Device__ Set when the -mcpu option specifies a device rather than an architecture. It indicates the device, for example when compiling for an atmega8, the macro __AVR_ATmega8__ will be set.
__AVR_DEVICE_NAME__ Set when the -mcpu option specifies a device rather than an architecture. It indicates the device, for example when compiling for an atmega8 the macro is defined to atmega8.
__AVR_ARCH__ Indicates the device architecture. Possible values are: 2, 25, 3, 31, 35, 4, 5, 51, 6 for the avr2, avr25, avr3, avr31, avr35, avr4, avr5, avr51, avr6, architectures respectively and 100, 102, 103, 104, 105, 106, 107 for the avrtiny, avrxmega2, avrxmega3, avrxmega4, avrxmega5, avrxmega6, avrxmega7, architectures respectively.
__AVR_ASM_ONLY__ Indicates that the selected device can only be programmed in assembly.
__AVR_CONST_DATA_IN_CONFIG_MAPPED_PROGMEM__ Indicates that const-qualified objects will be placed in a 32 KB program section that will be mapped into data memory.
__AVR_CONST_DATA_IN_PROGMEM__ Indicates that const-qualified objects will be placed in program memory.
__AVR_ERRATA_SKIP__

__AVR_ERRATA_SKIP_JMP_CALL__

Indicates the selected device (AT90S8515, ATmega103) must not skip (SBRS, SBRC, SBIS, SBIC, and CPSE instructions) 32-bit instructions because of a hardware erratum. The second macro is only defined if __AVR_HAVE_JMP_CALL__ is also set.
__AVR_HAVE_EIJMP_EICALL__ Indicates the selected device has more then 128 KB of program memory, a 3-byte wide program counter, and the eijmp and eicall instructions.
__AVR_HAVE_ELPM__ Indicates the selected device has the elpm instruction.
__AVR_HAVE_ELPMX__ Indicates the device has the elpm Rn,Z and elpm Rn,Z+ instructions.
__AVR_HAVE_JMP_CALL__ Indicates the selected device has the jmp and call instructions and has more than 8 KB of program memory.
__AVR_HAVE_LPMX__ Indicates the selected device has the lpm Rn,Z and lpm Rn,Z+ instructions.
__AVR_HAVE_MOVW__ Indicates the selected device has the movw instruction, to perform 16-bit register-register moves.
__AVR_HAVE_MUL__

__AVR_HAVE_MUL__

Indicates the selected device has a hardware multiplier.
__AVR_HAVE_RAMPD__

__AVR_HAVE_RAMPX__

__AVR_HAVE_RAMPY__

__AVR_HAVE_RAMPZ__

Indicates the device has the RAMPD, RAMPX, RAMPY, or RAMPZ special function register, respectively.
__AVR_HAVE_SPH__

__AVR_SP8__

Indicates the device has a 16- or 8-bit stack pointer, respectively. The definition of these macros is affected by the selected device, and for avr2 and avr25 architectures.
__AVR_HAVE_8BIT_SP__

__AVR_HAVE_16BIT_SP__

Indicates the whether 8- or 16-bits of the stack pointer is used, respectively, by the compiler. The -mtiny-stack option will affect which macros are defined
__AVR_ISA_RMW__ Indicates the selected device has Read-Modify-Write instructions (xch, lac, las and lat).
__AVR_MEGA__ Indicates the selected devices jmp and call instructions.
__AVR_PM_BASE_ADDRESS__=addr Indicates the address space is linear and program memory is mapped into data memory. The value assigned to this macro is the starting address of the mapped memory.
__AVR_SFR_OFFSET__=offset Indicates the offset to subtract from the data memory address for those instructions (e.g. in, out, and sbi) that can access SFRs directly.
__AVR_SHORT_CALLS__ Indicates the use of the -mshort-calls option, which affects the call instruction used and which can be set automatically.
__AVR_TINY__ Indicates that the selected device or architecture implements the avrtiny core. Note that some ATtiny devices do not use the avrtiny core.
__AVR_TINY_PM_BASE_ADDRESS__=addr Deprecated; use __AVR_PM_BASE_ADDRESS__. Indicates the avrtiny core device address space is linear and program memory is mapped into data memory.
__AVR_XMEGA__ Indicates that the selected device or architecture belongs to the XMEGA family.
__AVR_2_BYTE_PC__ Indicates the selected device has up to 128 KB of program memory and the program counter is 2 bytes wide.
__AVR_3_BYTE_PC__ Indicates the selected device has at least 128 KB of program memory and the program counter is 3 bytes wide.
__BUILTIN_AVR_name Indicates the names built-in feature is available for the selected device
__CODECOV When code coverage is enabled, with value __CC_RAM (1).
__DEBUG When performing a debug build and you are using the MPLAB X IDE.
__FLASHn Defines __FLASH, __FLASH1, __FLASH2 etc, based on the number of flash segments on the selected device.
__LINE__ Indicates the source line number.
__MEMX Indicates the __memx specifier is available for the selected device.
__NO_INTERRUPTS__ Indicates the use of the -mno-interrupts option, which affects how the stack pointer is changed.
__DATE__ Indicates the current date, e.g., May 21 2004.
__FILE__ Indicates this source file being preprocessed.
__TIME__ Indicates the current time, e.g., 08:06:31.
__XC Indicates MPLAB XC compiler for Microchip is in use.
__XC8 Indicates MPLAB XC compiler for Microchip 8-bit devices is in use
__XC8_VERSION Indicates the compiler’s version number multiplied by 1000, e.g., v1.00 will be represented by 1000.