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/TM4C123GH6PM: Extracting a build variable from source code #define.

Part Number: TM4C123GH6PM


Tool/software: Code Composer Studio

Is there a way to take a value defined in a C header (#define VERSION 0x1234) and automatically be able to use it as a Code Composer build variable?

Here is my situation: I have a version variable where I define the version of my source files such as define VERSION 201704101234ULL. I want to take this number (or a string if need be) and automatically name the .out file with the version number. I could manually enter the number in the project settings, by I am trying to make it as automated as possible to reduce the cases where they get out of sync. I have done the opposite by using build vars in my code, but in this case the version number is automatically generated into the .h file and I need to extract it to the build settings. I am also open to suggestions using a pre-build step and a .bat file, but in all cases I need a way to write a build variable to the project automatically.

Has anybody done this?

  • One idea is to write a script or batch file to create a file named macros.ini that has a variable assigned to the desired string. For example, the file would contain:

    [string] TESTVAR = 201704101234ULL

    The macros.ini file, if placed in the project directory will be read during project import (or the file can be imported separately as well) and the variable will then be available as a build variable to use in your build options. Some info on this file is available here.

  • This does work, but I was looking for a way to automatically pull in a variable from a source file every build without having to manually import it.

  • Unfortunately I am not aware of a way to automatically pull in a variable from a source file. I will give this some more thought and if I find a way to do this, I will post an update.