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.

C2000 Linker Problem : __attribute__ ((used)) ignored



I am using TI C2000 codegen tools 6.2.9 with GCC extensions enabled.

It seems that the __attribute__ ((used))  has no effect. When placing the following unused variable definition in my code, the linker will strip it out.

const unsigned char  MyUnusedString[] __attribute__ ((used)) = "text";

One the other hand, if #pragma RETAIN is used, the unused variable will be retained by the linker.

#pragma RETAIN(MyUnusedString)
const unsigned char  MyUnusedString[]  = "text";

Is this expected behavior?