I'm working with some code that was originally written for IAR and converting it to compile using a GCC compiler.
However I'm stuck with one particular line as I don't understand the syntax or what is going on.
__root const uint32_t part_number @ ".part_number" = 701052;
The __root I've found out is so that the the variable is included in the final code even if there is nothing that actually references it. const means that it won't change and is kept in the ROM instead of RAM.
It is the @ ".part_number" part that I don't follow. The specific error I get is "stray '@' in program".
I understand that @ isn't a part of standard C, but I haven't had any luck finding anything that explains this syntax I'm seeing.
If anyone is able to explain it, I would really appreciate it.
Thanks
From this KB entry it looks like it's syntax to instruct the linker to place the variable into a specific section.
If you instead place the object into a named segment:
__no_init struct setup located_configuration @ "SETUP";
The equivalent gcc syntax is through the section
attribute.
const uint32_t part_number __attribute__ ((section (".part_number")) = 701052;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With