In the code below, I would like the value of THE_VERSION_STRING to be taken from the value of the environment variable MY_VERSION at compile time>
THE_VERSION_STRING
MY_VERSION
If I recall correctly, you can use the command line parameter -D with gcc to #define a value at compile time.
#define
i.e.:
$ gcc file.c -o file -D"THE_VERSION_STRING=${THE_VERSION_STRING}"