2

A game has this: enter image description here

I'm curious to whether this was the actual build time, and sure enough, the 'File Last Modified' date of Crysis.exe (the program) is 03/31/2009, 01:40.

Sure, the developer could easily have manually inputted that value, and built the application in under a minute, but I'm curious to whether it is actually possible to input the current date/time (to the nearest second) when the application is actually building.

This would have many advantages, including easy identification of different builds of the application.

Is this possible?

AStopher
  • 4,207
  • 11
  • 50
  • 75

2 Answers2

4

Yes the time of built is provided by the __TIME__ macro. In your example they also use __DATE__ macro which provides the date.

LIVE DEMO

101010
  • 41,839
  • 11
  • 94
  • 168
1

Yes. Several approaches come to mind:

  1. Use C's __DATE__ and __TIME__ macros. They're part of the standard, however, they take the time the particular file was last built. So that means if you e.g. put the build date in your app's about screen, then the date will only be updated when you either do a complete clean build, or you change the about screen source file. To fix this, you could add a script to your build process that e.g. calls

    touch AboutScreen.cpp
    

    To forcibly trigger a rebuild.

  2. Write a shell script that you run before each build that generates a header file like

    #define BUILD_DATE  "2014-07-03 20:15"
    

    and run that script before each build. Since the file is generated new each time, your build process should notice it has changed and automatically trigger a new build of the about screen or whatever shows your build date/time.

uliwitness
  • 8,532
  • 36
  • 58
  • Serious companies always use clean builds when releasing. That prevents such issues. It also helps a lot in making builds reproducable. – MSalters Jul 04 '14 at 08:38
  • 1
    Fully agreed. But if you're just throwing a quick build to a colleague to verify a fix and they find it on their hard disk a month later, it helps to have the proper date and time in there even then. Besides, I doubt "serious companies" describes all the visitors to Stack Overflow. :-) – uliwitness Jul 04 '14 at 09:50