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.

Using predefined preprocessor symbols in linker command file

I'm trying to use the __TI_COMPILER_VERSION__ preprocessor symbol in my linker command file. The section looks like this:

#if __TI_COMPILER_VERSION__ > 6000000
  /* do something */
#else
  /* do something else */
#endif

I keep getting this warning

warning #19014-D: undefined preprocessor symbol '__TI_COMPILER_VERSION__'

and linking fails when building with CCSv5.3 (code gen tools v6.1.3) because the linker attempts to execute the else part. Is it not possible to use any of the predefined symbols? Does it have to be a user defined symbol?

  • I presume you are using the C28x tools.  Please see the last part of the section titled Link Command File Preprocessing in the C28x assembly tools manual.  The symbol __TI_COMPILER_VERSION__ is not predefined.

    Thanks and regards,

    -George

  • Hi George,

    Thanks, that answers my question (even though it's not what I wanted to hear). Is there any option to do conditional preprocessing in the linker command file other than a user-defined symbol?

    The __TI_COMPILER_VERSION__ symbol was ideal for my use case since I was trying to maintain the same linker command file between CCSv3.3 and CCSv5.3 (I need this since the current working directory from the compiler's point of view has changed between the two versions).

  • Ashish Sadanandan said:
    Is there any option to do conditional preprocessing in the linker command file other than a user-defined symbol?

    No.  But you could do something like this ...

    #ifndef CMD_LINE_VAR
    #error CMD_LINE_VAR must be defined
    #endif

    This requires that --define=CMD_LINE_VAR must appear among the linker options.

    Not quite as smooth as a compiler predefined symbol.  But when someone makes a mistake, they know about it right away.

    Thanks and regards,

    -George