__attribute__变量属性

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 */
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值