Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Refer to Compiler Version in Your Source

From Texas Instruments Wiki
Jump to: navigation, search

Sometimes you need to refer to the version of the compiler from your source code. You can use the compiler predefined preprocessor macro __TI_COMPILER_VERSION__. Here is an example.

 // ver_ex.c
 // Examples of how to use __TI_COMPILER_VERSION__, the preprocessor
 // symbol predefined by all TI compilers
 int val = __TI_COMPILER_VERSION__;                   // as an int
 #define EVAL_TO_STR(arg) #arg
 #define MKSTR(arg) EVAL_TO_STR(arg)
 char *cgt_version = MKSTR(__TI_COMPILER_VERSION__);  // as a string

Note relatively old versions of TI compilers do not supply __TI_COMPILER_VERSION__. To see if your compiler supports it, preprocess the example with the option -ppc and examine the resulting .pp file. If __TI_COMPILER_VERSION__ is supported, it will look something like this.

C:\dir>cl6x -ppc ver_ex.c
C:\dir>type ver_ex.pp
// ver_ex.c
// Examples of how to use __TI_COMPILER_VERSION__, the preprocessor
// symbol predefined by all TI compilers
int val = 6001000;                   // as an int
char *cgt_version = "6001000";  // as a string