c++ - How can I find out the date of when my source code was compiled? -


is possible store , display date of when project compiled?

i'd print date when program starts in order know version used. currently, doing hand, rather cumbersome.

i using visual studio 2010.

you can use __date__ , __time__ macros - see "predefined macros" here.

as sample, this:

#include <iostream> int main() {     using namespace std;     cout << "compiled on: " << __date__ << endl;     cout << "compiled at: " << __time__ << endl; } 

you modify messages , use according needs.

you building larger macro or named variable.

#include <iostream> const char* const compiled = __date__ " @ " __time__; int main() {     using namespace std;     cout << "compiled: " << compiled << endl; } 

if "version" information tied source control location or data (such commit number), may idea include data in build via build step or command line define of sort. should consider effect of incremental builds on date , time. i'm assuming "release" builds not incremental based, or if so, there "touch" on file containing date , time data.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -