使用TI(德州仪器)编译器时,我可以通过ADC12IFG = 50;
使用C ++设置嵌入式微控制器的存储位置。 Clang将此代码标记为错误:indirection requires pointer operand ('int' invalid)
。因此,当我深入研究时,TI有一个头文件msp430f5335.h,它有以下几行:
#define SFR_16BIT(address) extern volatile unsigned int address
SFR_16BIT(ADC12IFG); /* ADC12+ Interrupt Flag */
然后有一个链接器命令文件msp430f5335.cmd,其中包含以下行:
ADC12IFG = 0x070A;
所以看起来链接器命令文件指定address
。那么是否有可能让clang分析工具识别链接器命令文件而不会导致误报?
答案 0 :(得分:0)
Clang旨在与GCC兼容。
TI的头文件(msp430-gcc-support-files
)使用以下机制来定义内存映射寄存器变量:
#define sfrw_(x,x_) extern volatile unsigned int x asm(#x_)
#define sfrw(x,x_) sfrw_(x,x_)
#define ADC12IFG_ 0x070A /* ADC12+ Interrupt Flag */
sfrw(ADC12IFG, ADC12IFG_);
(这不需要链接器命令文件。)