Refer to Compiler Version in Your Source

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

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
E2e.jpg For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Refer to Compiler Version in Your Source here.
Hyperlink blue.png Links
ARM Microcontroller MCU ARM Processor Digital Media Processor Digital Signal Processing Microcontroller MCU Multi Core Processor
Ultra Low Power DSP 8 bit Microcontroller MCU 16 bit Microcontroller MCU 32 bit Microcontroller MCU

Leave a Comment
Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox