根据以下链接: ARM编译器6
ARM 编译器 6 不再支持“attribute((at()))”,而是将其替换为“attribute((section(".ARM._at")))”
如果我想使用arm编译器6将变量放置在位置0x20000000,我会这样做:
int var __attribute__((section(".ARM.__at_0x20000000")));
但是我要将地址隐藏在 #define ADDR 0x20000000 下 并将其用作:
#define ADDR 0x20000000
int var __attribute__((section(".ARM.__at_ADDR")));
我从链接器收到错误: L6974E:ADDR 没有基地址
有没有办法使用#defines来指定放置变量的地址?
您可以使用“stringify”和字符串连接。
// Traditional stringify.
#define xstr(s) str(s)
#define str(s) #s
#define ADDR 0x20000000
int var attribute((section(".ARM.__at_" str(ADDR))));
字符串连接就是将两个相邻的字符串常量连接起来。