Time of build as program version

I would like to have variable that holds time and date of build.
I have few classes and __TIMESTAMP__ is updated only if code is changed (class where __TIMESTAMP__ is ).

Visual C++ 2008 Express

Best regards,
Peter
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <string>
#include <iostream>

using namespace std;

int main()
{
 string time(__TIME__);
 string date(__DATE__);

 cout << time << endl;
 cout << date << endl;

 return 0;
}
I have more than one class.

__TIME__, __DATE__, and __TIMESTAMP__ are updated when main() source file is changed.
If you have macro in some other class, then it is updated only if that class (source code) is changed and rebuild.
I need some sort of global variable.

BR,
Peter
Last edited on
I have a question here.. where are these _TIME_ _DATE_ macros defined?
They are compiler intrinsic.
Does the standard mandate any set of macros to be implemented...
yes.
touch.exe is what I was looking for.

Best regards,
Peter
Instead of using touch, you can just add and delete a space, then save.
Topic archived. No new replies allowed.