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.

CODECOMPOSER: .out file preamble/header

Part Number: CODECOMPOSER

Hi,
I would like to ask if it is possible, when building a program in CCS, to add a preamble/header to the .out file which will contain e.g. software version, date etc.? What I mean is that if I have an .out file, I could turn it on in notepad and be able to see what version of code is in that file?

If this is possible, is there an option to have this done automatically every time the program is built? And is there an option to have, for example, the git commit number downloaded when creating the preamble?

  • if it is possible, when building a program in CCS, to add a preamble/header to the .out file

    Unfortunately, no.

    Here is a different solution to consider.  In one file in the program, write code similar to ...

    __attribute__((retain))
    static char *version_string = "MY COMPANY SOFTWARE VERSION: 1.2.3";

    I presume you have access to the command strings available in most Unix-like environments (Linux, Cygwin, macOS, etc.).  Then you can run a command similar to ...

    $ strings executable_file.out | grep "MY COMPANY SOFTWARE VERSION"
    MY COMPANY SOFTWARE VERSION: 1.2.3

    Thanks and regards,

    -George

  • Thank you for your reply. 
    Your answer gave me the idea of adding in the pre-build options a script that executes in git bash that takes the commit number/tags/date and creates a .h file with a variable storing this information. I'm still struggling to somehow make sense of storing this in flash memory, but I already have an idea.

    Here's an example snippet of the script in case anyone needs it for future reference:

    git log --pretty=format:"#define GIT_INFO_PRESENT %%n const char* GIT_INFO = \"[%%H, %%d]\"; %%n " -n 1 > ../Version/FWversion.h