Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compiling in compile time?

0 views
Skip to first unread message

Ron Olson

unread,
Jun 9, 1998, 3:00:00 AM6/9/98
to

Hey all-

I am writing a program in DevStudio that has a console (no gui). One of the
things I want to provide is the time and date the app was compiled. Even
though I have been working at it for quite awhile, I still have not mastered
remembering to change the #defines every time I compile, so I was thinking
about using the vbscript stuff to, when I hit compile, do as a prestep
record the time and date, search for the #define, replace it, then proceed
with the compile.

This seems unnecessarily silly, and was wondering if there was a simpler
way, perhaps some maco Microsoft has in there that I'm not aware of.

I also wanted to do this for the build number, this I understand I would
need such a method as described above.

Neil Mowbray

unread,
Jun 15, 1998, 3:00:00 AM6/15/98
to

Have a cpp file with the __FILE__, __TIME__ macros in, eg,

const char *
MeSignature()
{
static char resultBuffer[100];
#ifdef _DEBUG
sprintf(resultBuffer, "Thing, built %s %s Debug", __DATE__, __TIME__);
#else
sprintf(resultBuffer, "Thing, built %s %s Release", __DATE__,
__TIME__);
#endif
return resultBuffer;
}

then add a pre-build rule to DevStudio (under settings on the right mouse
popup
menu when file is selected) that touches this file. You can get
touch.exe from the NT resource kit, or

main(...)
{
HANDLE h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, 0,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

SYSTEMTIME s;
GetSystemTime(&s);
FILETIME f;
SystemTimeToFileTime(&s, &f);

SetFileTime(h, 0, &f, &f);
CloseHandle(h);

return 0
}

Ron Olson wrote in message <6lkfhi$e...@NYCSEX0001.btco.com>...

0 new messages