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.

CCS/TMS320F28335: I added a version string to my code using the $current_date compiler variable but it gets compiled out of my code

Part Number: TMS320F28335

Tool/software: Code Composer Studio

I added a version string to my code using the $current_date compiler variable but it gets compiled out of my code.

I set a string with this line in my code:

char versiont[20] = TIMESTAMP;

TIMESTAMP is defined in the predefined name section of CCS with this definition:

TIMESTAMP="\""${current_date}"\""

However, version is always compiled out unless I use it in my code. I worked around this by setting some other variable (that gets overwritten) to one of the elements of version but this seems like bad coding.  I want this string for checking in CCS but currently I do not need to use it in the execution of my code.  I tried the following:

     static volatile char versiont[20] = TIMESTAMP;

     volatile char versiont[20] = TIMESTAMP;

     char version[20] __attribute__ ((used))= TIMESTAMP;

and the "full Monty":

static volatile char versiont[20]  __attribute__ ((used)) = TIMESTAMP;

but none of these worked.

I also tried the -Retain linker option but got an error because I use COEF instead of EFL for my code output. (Should I be using ELF for some reason?? Will changing to ELF cause any other issues?)

Does anyone know how to make this variable survive linking without being used in the code?

Regards,

Neil