Skip to content

Commit 9b25bf2

Browse files
committed
[build-tools] fixed AutoVersion's MSVC warnings
1 parent ac9d8f7 commit 9b25bf2

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

src/common/AutoVersion.exe

-7.5 KB
Binary file not shown.

src/common/autoversion.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Rev: 7109 @ 2011-04-15T11:53:16.901970Z
33
//Now released as WTFPL
44
#include <stdio.h>
5+
#include <stdint.h>
56
#include <time.h>
67
#include <string.h>
78
#include <string>
@@ -95,12 +96,12 @@ enum VersionFlags{
9596
VER_DIRTY = 0x01,
9697
};
9798
struct Version{
98-
unsigned char flags_;
99-
unsigned char major;
100-
unsigned short minor;
101-
unsigned short build;
102-
unsigned char status;
103-
unsigned int revision;
99+
uint32_t flags_;
100+
uint32_t major;
101+
uint32_t minor;
102+
uint32_t build;
103+
uint32_t status;
104+
uint32_t revision;
104105
time_t timestamp;
105106
string url;
106107
string date;
@@ -344,9 +345,9 @@ int main(int argc, char** argv)
344345
Version ver = {0};
345346
ver.date = "unknown date";
346347

347-
// printf("Version: %u.%hu.%hu.%hu #%u\n",ver.major,ver.minor,ver.build,ver.status,ver.revision);
348+
// printf("Version: %u.%u.%u.%u #%u\n",ver.major,ver.minor,ver.build,ver.status,ver.revision);
348349
ReadHeader(headerPath, ver);
349-
// printf("Version: %u.%hu.%hu.%hu #%u\n",ver.major,ver.minor,ver.build,ver.status,ver.revision);
350+
// printf("Version: %u.%u.%u.%u #%u\n",ver.major,ver.minor,ver.build,ver.status,ver.revision);
350351
unsigned int rev = ver.revision;
351352
if(g_repo&REPO_GIT){
352353
if(QueryGit(Gitpath,&ver))
@@ -373,7 +374,7 @@ int main(int argc, char** argv)
373374
// if(g_repo){ // increase revision because on commit the revision increases :P
374375
// ++ver.revision; // So we should use the "comming" revision and not the previous (grml... date and time is wrong though :/ )
375376
// }
376-
// printf("Version: %u.%hu.%hu.%hu #%u\n",ver.major,ver.minor,ver.build,ver.status,ver.revision);
377+
// printf("Version: %u.%u.%u.%u #%u\n",ver.major,ver.minor,ver.build,ver.status,ver.revision);
377378
if(rev!=ver.revision){
378379
ver.flags_ |= VER_DIRTY;
379380
puts(" - increased revision");
@@ -582,13 +583,13 @@ bool ReadHeader(const char* filepath,Version &ver)
582583
void PrintDefine(FILE* fp,const char* define,const Version &ver)
583584
{
584585
if(!strcasecmp("MAJOR",define)) {
585-
fprintf(fp,"%hu",ver.major);
586+
fprintf(fp,"%u",ver.major);
586587
}else if(!strcasecmp("MINOR",define)) {
587-
fprintf(fp,"%hu",ver.minor);
588+
fprintf(fp,"%u",ver.minor);
588589
}else if(!strcasecmp("BUILD",define)) {
589-
fprintf(fp,"%hu",ver.build);
590+
fprintf(fp,"%u",ver.build);
590591
}else if(!strcasecmp("STATUS",define)) {
591-
fprintf(fp,"%hu",ver.status);
592+
fprintf(fp,"%u",ver.status);
592593
}else if(!strcasecmp("STATUS_FULL",define)) {
593594
fprintf(fp,"%s",STATUS_S[ver.status]);
594595
}else if(!strcasecmp("STATUS_SHORT",define)) {
@@ -601,19 +602,19 @@ void PrintDefine(FILE* fp,const char* define,const Version &ver)
601602
// version strings
602603
}else if(!strcasecmp("FULL",define)) {
603604
if(STATUS_S[ver.status][0])
604-
fprintf(fp,"%hu.%hu.%hu %s",ver.major,ver.minor,ver.build,STATUS_S[ver.status]);
605+
fprintf(fp,"%u.%u.%u %s",ver.major,ver.minor,ver.build,STATUS_S[ver.status]);
605606
else
606-
fprintf(fp,"%hu.%hu.%hu",ver.major,ver.minor,ver.build);
607+
fprintf(fp,"%u.%u.%u",ver.major,ver.minor,ver.build);
607608
}else if(!strcasecmp("SHORT",define)) {
608-
fprintf(fp,"%hu.%hu%s%hu",ver.major,ver.minor,STATUS_SS[ver.status],ver.build);
609+
fprintf(fp,"%u.%u%s%u",ver.major,ver.minor,STATUS_SS[ver.status],ver.build);
609610
}else if(!strcasecmp("SHORT_DOTS",define)) {
610-
fprintf(fp,"%hu.%hu.%hu",ver.major,ver.minor,ver.build);
611+
fprintf(fp,"%u.%u.%u",ver.major,ver.minor,ver.build);
611612
}else if(!strcasecmp("SHORT_GREEK",define)) {
612-
fprintf(fp,"%hu.%hu%s%hu",ver.major,ver.minor,STATUS_SS2[ver.status],ver.build);
613+
fprintf(fp,"%u.%u%s%u",ver.major,ver.minor,STATUS_SS2[ver.status],ver.build);
613614
}else if(!strcasecmp("RC_REVISION",define)) {
614-
fprintf(fp,"%hu, %u, %u, %u",ver.major,ver.minor,ver.build,ver.revision);
615+
fprintf(fp,"%u, %u, %u, %u",ver.major,ver.minor,ver.build,ver.revision);
615616
}else if(!strcasecmp("RC_STATUS",define)) {
616-
fprintf(fp,"%hu, %u, %u, %u",ver.major,ver.minor,ver.build,ver.status);
617+
fprintf(fp,"%u, %u, %u, %u",ver.major,ver.minor,ver.build,ver.status);
617618

618619
// repository
619620
}else if(!strcasecmp("REVISION_URL",define)) {
@@ -623,7 +624,7 @@ void PrintDefine(FILE* fp,const char* define,const Version &ver)
623624
}else if(!strcasecmp("REVISION_HASH",define)) {
624625
fprintf(fp,"%s",ver.revhash.c_str());
625626
}else if(!strcasecmp("REVISION_TAG",define)) {
626-
fprintf(fp,"v%hu.%hu.%hu#%hu",ver.major,ver.minor,ver.build,ver.revision);
627+
fprintf(fp,"v%u.%u.%u#%u",ver.major,ver.minor,ver.build,ver.revision);
627628
if(STATUS_S[ver.status][0]){
628629
fputc('-',fp);
629630
for(const char* c=STATUS_S[ver.status]; *c; ++c){

src/~ide/msvc-cb-autoversion.cbp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<Add option="/EHc" />
2727
<Add option="/EHs" />
2828
<Add option="/W4" />
29+
<Add option="/wd4706" />
2930
</Compiler>
3031
<Unit filename="../common/autoversion.cpp" />
3132
<Unit filename="../common/getopt_tools.c">

src/~ide/msvc-vs-autoversion.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
</PropertyGroup>
4949
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
5050
<ClCompile>
51+
<DisableSpecificWarnings>4706;</DisableSpecificWarnings>
5152
<Optimization>Disabled</Optimization>
5253
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
5354
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -67,6 +68,7 @@
6768
</ItemDefinitionGroup>
6869
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
6970
<ClCompile>
71+
<DisableSpecificWarnings>4706;</DisableSpecificWarnings>
7072
<Optimization>MinSpace</Optimization>
7173
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
7274
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>

0 commit comments

Comments
 (0)