TITLE: inserting build times into code (Newsgroups: comp.lang.c++.moderated, 17 Aug 97) BENDER: Dave Bender > > Is it possible to get the time that a program was compiled or built into > the program itself? > > I'd like to do that as an easy way to see which program is running as my > program moves into it's testing phase (gotta couple copies). I'm being > nice and orderly about it, but it would be nice to have it cout << the > compiled time. > > Is this something the preprocessor could do? ODOWD: "Robert O'Dowd" It is something the preprocessor does, and is part of the standard. The macro __DATE__ expands to a string that contains the date of translation, in the form "Mmm dd yyyy" if memory serves. The macro __TIME__ expands to a string that contains the time of translation, in the form "hh:mm:ss". Neither of these macros can be explicitly undefined or redefined. The "time of translation" is obviously related to compilation time or when the preprocessor is run.