attribute((at(address))) variable attribute
语法
attribute((at(address)))
Where:
address
is the desired address of the variable.
Usage
The variable is placed in its own section, and the section containing the variable is given an appropriate type by the compiler:
1.Read-only variables are placed in a section of type RO.
2.Initialized read-write variables are placed in a section of type RW.
Variables explicitly initialized to zero are placed in:
1).A section of type ZI in RVCT 4.0 and later.
2).A section of type RW (not ZI) in RVCT 3.1 and earlier. Such variables are not candidates for the ZI-to-RW optimization of the compiler.
3.Uninitialized variables are placed in a section of type ZI.
限制
The linker is not always able to place sections produced by the at variable attribute.
The compiler faults use of the at attribute when it is used on declarations with incomplete types.
Note
GNU 编辑器不支持这种变量属性
Example
const int x1 __attribute__((at(0x10000))) = 10; /* RO */
int x2 __attribute__((at(0x12000))) = 10; /* RW */
int x3 __attribute__((at(0x14000))) = 0; /* RVCT 3.1 and earlier: RW.
* RVCT 4.0 and later: ZI. */
int x4 __attribute__((at(0x16000))); /* ZI */