1

When using TI (Texas Instrument) compiler, I am able to set a memory location of embedded micro-controller using C++ by simply ADC12IFG = 50;. Clang marks this code as error: indirection requires pointer operand ('int' invalid). So when I dig into it, TI has a header file, msp430f5335.h which has the following lines:

#define SFR_16BIT(address)  extern volatile unsigned int address
SFR_16BIT(ADC12IFG);                          /* ADC12+ Interrupt Flag */

Then there is a linker command file, msp430f5335.cmd which has the following line:

ADC12IFG           = 0x070A;

So it looks like the linker command file specifies the address. So is it possible to have clang analysis tool recognize the linker command file and not cause a false positive?

user1135541
  • 1,781
  • 3
  • 19
  • 41

1 Answers1

0

Clang is intended to be GCC compatible.

TI's header files (msp430-gcc-support-files) use the following mechanism to define memory-mapped register variables:

#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_);

(This does not require a linker command file.)

CL.
  • 173,858
  • 17
  • 217
  • 259