Compilation time/date

Mike Stump
Mon Sep 18 17:17:00 GMT 2000

> Date: Mon, 18 Sep 2000 15:26:35 -0700 (PDT)
> From: Ovanes Manucharyan <>
> To:

> I am aware that binaries compiled using HP's ACC compiler have the
> compilation date/time embedded in them.

This is generally considered to be a non-feature.

> What kind of a data structure houses such information. And is this
> information, compilation date/time, kept in a standardized manner or
> does it vary from compiler to compiler?

It varies from OS to OS, more than anything.  You can access the file
modification time, this will have date of last modification.  If one
uses cp -p and other such methods to make copies, then the time on the
file, will be the time when it was compiled.  I'd recommend that.
After that, you can record that time and date anyplace you want during
compilation, and use that information.  For example:


	char time_and_date[] = foo(__TIME__, __DATE__);

and then you can get at it via time_and_date.  Or, you can log it to a
data file during the build, and store it someplace else...

Lots of possibilities.  For more information on any OS specific time
and date built in, a better place to ask would be to ask on a OS
specific list.  You can find out what you system does, by compiling:

int main() { return 0; }

twice, at least a second or so apart, and seeing if the two binaries
differ.  If they do, then the difference is probably due to the time
and date.  If you run od -x on the two, you can probably reverse
engineer it, if you can't find the information someplace.

More information about the Gcc mailing list