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.
Tool/software: TI C/C++ Compiler
Hello,
I have an initialized static const global variable which is NOT used anywhere in the code but i would like to keep (dont want it to be optimized out but linker/compiler).
I have added the used attribute and the retain pragma but it still does not work. i also tried adding --retain in the linker command file (to see if there is a problem with the pragma) but it did not help either.
I am using TDA2xx , the M4 core , compiler version: Ti.16.9.2.LTS
[update]: the --keep_unneeded_statics compiler option seem to help but the problem is that this option is a global one and not for a specific variable and i want only a specific variable to be kept
Can you please help - why does this work?
Thanks
Guy
Please used #pragma RETAIN instead. Look that up in the ARM compiler manual. In a future release, you will be able to use __attribute__((retain)).
Thanks and regards,
-George
I'm sorry I overlooked that.
As a workaround, please try what this customer did.
At the same time, this seems like a real problem in the compiler. So, I'd appreciate a test case. For the C source file where you use #pragma RETAIN to no effect, please submit a test case as described in the article How to Submit a Compiler Test Case.
Thanks and regards,
-George
I am able to construct a small test case which exhibits similar behavior. I filed CODEGEN-5119 in the SDOWP system to have this investigated. You are welcome to follow it with the SDOWP link below in my signature.
I am concerned that my test case may not match the details of your case. One or more of those details could have a role in the problem behavior. That is why I still would like to have the test case I requested earlier.
Thanks and regards,
-George
Hi,
Below is an example to what i have (nothing much really)
#pragma RETAIN(testStr)
__attribute__((used)) static const char testStr[]="TESTING 123";
main()
{
...
}
The global static variable (testStr) is NOT referenced anywhere in the code !
Also the fix (when there is one) should also apply with and without compiler optimization...
Thanks
Guy