visual c++ - c++ Auto Increment Build Version By Time & Date -
i trying create auto increment build version time & date
i couldnt add date & time in #define
version.h file
#define stringize2(s) #s #define stringize(s) stringize2(s) #define version_major 5 #define version_minor 0 #define version_revision 2 #define version_build 1 #define productver version_major, version_minor, version_revision, version_build #define strfilever stringize(version_major) "." stringize(version_minor) "." stringize(version_revision) "." stringize(version_build) .rc file
vs_version_info versioninfo fileversion productver productversion productver value "fileversion", strfilever value "productversion", strfilever i tried
#define version_major __date__ #define version_minor __time__ #define version_revision 2 #define version_build 1 also tried other ways
time_t now; struct tm *current; = time(0); current = localtime(&now); #define version_major current->tm_wday #define version_minor current->tm_hour #define version_revision 2 #define version_build 1 nothing succeed
i wanted add day , hour in define
i hope there solution
thank you
given example below, have build script modify value in version text.
static const char version_text[] = "519"; char const * version_get_text(void) { return version_text; } unsigned int version_text_length(void) { return sizeof(version_text) - 1u; } no need messy #define macros. functions preserve run-time , type safety: none of files accessing these functions need rebuilt when version changes; module.
this technique, combined our automated build server, has lasted year far no issues.
also, no optimizations necessary. accessing version not part of core operations of our product; happens during initialization when debug prompt first displayed or when user sends command asking version. in these cases, execution time not critical.
Comments
Post a Comment