Time of build as program version

Jun 22, 2010 at 7:25am
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 Jun 22, 2010 at 7:32am
Jun 22, 2010 at 7:30am
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;
}
Jun 22, 2010 at 7:36am
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 Jun 22, 2010 at 8:21am
Jun 22, 2010 at 6:08pm
I have a question here.. where are these _TIME_ _DATE_ macros defined?
Jun 22, 2010 at 6:25pm
They are compiler intrinsic.
Jun 23, 2010 at 12:34am
Does the standard mandate any set of macros to be implemented...
Jun 23, 2010 at 1:30pm
yes.
Jun 29, 2010 at 3:32pm
touch.exe is what I was looking for.

Best regards,
Peter
Jun 29, 2010 at 3:38pm
Instead of using touch, you can just add and delete a space, then save.
Topic archived. No new replies allowed.