How to enable build timestamp in VC ++ project?
I am converting a makefile project to a Visual Studio VC ++ project. This is actually the C source code.
One of the statements I have in my makefile:
echo char * gLibraryBuildSig ="%DATE% %TIME%"; > BuildTimestamp.c
This creates a C source file with one line in it:
char * gLibraryBuildSig ="Sun 08/23/2009 17:56:05.05";
Then in the makefile, I compiled all the C source code using cl.exe and after linking, I removed the BuildTimestamp.c file. This gives me a global symbol that provides the build time as a string.
How can I do the same in a VS2008 project? Mind you, this is not MSBuild.
I'm halfway there. To create a C module at build time in Visual Studio, I simply use the prebuild event.
How can I include this generated file in compilation and also exclude it from source control and project management?
Or is there a better way to do what I want?
source to share
The compiler (cl.exe) has predefined macros __DATE__
and__TIME__
as well __TIMESTAMP__
. You can compile a file containing just that as a pre-link step.
source to share