user3652454
user3652454

Reputation: 41

What is the use of @ symbol in the C language?

The symbol @ was seen in one of my programs. But I could not find out why it is used .

The syntax is

 const unsigned char Array_name[] @(INFO_Array+1) = {................};

Upvotes: 4

Views: 2251

Answers (2)

angrybobcat
angrybobcat

Reputation: 300

To me, it looks like a compiler flag to disable interpreting the string "INFO_Array+1" as an expression. In C#, for example, you can use the @ operator to tell the compiler to use the following expression as String without trying to evaluate it.

A quick googling showed:

For example, this line will fail to compile:

int new = 1776;   // 'new' is a keyword 

However, this line compiles without error:

int @new = 1776;

Upvotes: 0

tonyjosi
tonyjosi

Reputation: 827

The meaning of @ operator can be different for the particular compiler in which the code is compiled.

For example, in IAR Embedded Workbench's C/C++ compiler the @ operator can be used for placing global and static variables at absolute addresses.

If you are using IAR C/C++ compiler, the compiler will place Array_name in the address (INFO_Array+1).

@ operator can also be used to place a variable or object in a particular section of the object file:

uint32_t CTRL_OFFSET_x86 @ "MY_RAM_SECTION";

The above line will place CTRL_OFFSET_x86 in the object file section MY_RAM_SECTION.

#pragma location can also be used for this purpose.

Upvotes: 2

Related Questions