Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange definition in C with @ sign

Tags:

c

embedded

iar

I have come across following definition in an embedded C source file:

const preamble_t OAD_Preamble @ ".preamble" =
{
  HAL_OAD_RC_MAX,       // Default program length of max if not using post-processing tool.
  OAD_MANUFACTURER_ID,  // Manufacturer ID
  OAD_TYPE_ID,          // Image Type
  0x00000001            // Image Version
};

I have no idea about the @ part, can you please help me with this?

Edit: This is in IAR compiler, used with TI SoCs.

like image 201
doubleE Avatar asked Sep 17 '15 17:09

doubleE


1 Answers

This is the way you can specify a memory address or a section in which you would like to place your variable.

  • ".preamble" is the name of a section,
  • OAD_Preamble is the variable to be placed there.

You can also specify physical address after the at @ sign:

const unsigned char port_bit @ 0x1800 = BIT0;

More information is in this document.

Note: this is a non-portable compiler extension, not a part of the standard C syntax.

like image 89
Sergey Kalinichenko Avatar answered Oct 08 '22 04:10

Sergey Kalinichenko