We are using __TIME__
to embed the time of compilation in a binary. Unfortunately, a time without a UTC Offset is meaningless. I don't see an obvious way to get the timezone that the compiler is running in. I suppose I could grab this from the configure script. But is there a better way?
If I do it from a configure script, I'm going to need to put that into a .h or .c file somehow, and do something intelligent if the file is not there.
you can use compiler Flags to pass that externally. Most compiler provide '-D'
flag to define #define
macros externally. Let's suppose you put the UTC information in an environment variable. Pass that environment variable as -D
flag
set $myUTC="-7"
gcc -c mysource.cpp -DUTC=$myUTC
In your mysource.cpp
use the macro UTC
:
printf("Compiled at %d Offset %d", __TIME__, UTC);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With