This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler-agnostic no-init code

I was looking at slau132i.pdf, the "MSP430 Optimizing C/C++ Compiler v 4.3 User's Guide", section 5.11.19 "The NOINIT and PERSISTENT Pragmas".

There, it states to use the same constructs for CCS & IAR, though slightly different variants for C and C++...

However, for gcc, the suggestion is to use:

int x __attribute__((noinit));

However, gcc gives a warning when I use this construct:

'noinit' attribute directive ignored [-Wattributes]

...whereas, the construct I used to always use with gcc

int x __attribute__((section(".noinit")));

...works fine, i.e. places the declared variable in the correct noinit sections as verified by the map files...

Am I missing something?

  • It seems you presume that every attribute supported by the TI compiler must also be supported by GCC.  This is not the case.  We support the attribute syntax form for the the noinit feature simply as a convenience for those who prefer it, not because it matches anything GCC supports.

    Thanks and regards,

    -George

  • Thanks for your reply, however I suspect we are talking at cross-purposes.

    I read section 5.11.9 as implying that the equivalent in the gcc compiler (i.e. the RedHat gcc compiler) was to use "__attribute__((noinit))", not that this syntax is valid in TI's compiler.

    The RedHat compiler doesn't support the above syntax as noted above - I feel that the manual is unclear as to which instance of the compiler is being referred to... (TI's, mspgcc, RedHat gcc...)...

  • I understand your confusion.  But, unless it specifically says otherwise, all feature discussed, and all examples shown, refer only to the TI compiler.  

    Thanks and regards,

    -George