@ sign in C variable declaration

It's a compiler extension.

From PIC MPLAB XC8 compiler documentation (emphasis mine):

5.5.4 Absolute Variables

Most variables can be located at an absolute address by following its declaration with the construct @ address, where address is the location in memory where the variable is to be positioned. Such a variables is known as an absolute variables.

5.5.4.1 ABSOLUTE VARIABLES IN DATA MEMORY

Absolute variables are primarily intended for equating the address of a C identifier with a special function register, but can be used to place ordinary variables at an absolute address in data memory.

For example:

volatile unsigned char Portvar @ 0x06;

will declare a variable called Portvar located at 06h in the data memory. The compiler will reserve storage for this object (if the address falls into general-purpose RAM) and will equate the variable’s identifier to that address.

Note that MPLAB XC8 is not the only compiler to have the same @ construct to place an object in the specific memory location.

Another well known compiler is Freescale CodeWarrior (at least for HCS08).

Another one is IAR C Compiler (at least for MSP430 and AVR).


It's an extension in the PIC compiler, to place a variable at a specific memory position. No other compiler I know have that extension.