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.

alt text

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?

+2


source to share


2 answers


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.



+3


source


Another alternative is to use a preprocessor to include the generated file:

#include "BuildTimeStamp.c"

      



The file that includes this file can be one of the files in the project under source control.

0


source







All Articles