Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Build timestamp in C++

Status
Not open for further replies.

cheer8923

Programmer
Aug 7, 2006
230
US
On Unix, we have the following practice:

The command for the final executable has a timestamp automatically added:

app: ${OBJ}
date +"extern const double VERSION=%Y%m%d.%H%M%S" > version.cpp
gcc version.cpp ${OBJ} -o app

In VS, the Custom Build Step can be used to create version.cpp. However, I don't see any way to include it on the build line.

If I introduce a dummy file and make a custom build rule to generate version.cpp all the time, it will end up forcing a new link when nothing else changed -- on Unix, only when sth. changes the link command will be invoked.

Is there any way to do this in Visual Studio?
 
How about

1) Create a dummy project like AAA build everything. All other projects depend on it. This is the one with the custom build step.
2) If you want a development build, use what you use normally.
3) If you want a new date run the dummy project.
 
I've solved the problem by manually adding a pre-link event. In it, a cpp file has to be created and compiled. Then the resulting obj is added to the link line
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top