From: nhmall Date: Sat, 14 Aug 2021 19:36:54 +0000 (-0400) Subject: fix some VS warnings that recently appeared X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=29aca6276eb3fc089630aca1680d0e75416fddaf;p=nethack fix some VS warnings that recently appeared ..\src\explode.c(884): warning C4028: formal parameter 1 different from declaration That one stems from commit 6b60618e0e. Adjust the prototype in include/extern.h to match the function definition in src/explode.c Also, a recent update to the Microsoft Visual Studio 2019 causes the compiler to complain while compiling a vendor c++ header (string) if warning C4774 is enabled. We force that warning to be enabled during the Makefile build, even though it is not enabled by default. Only do so in the Makefile.msc for c source files, and not for c++ (sys/share/cppregex.cpp). See below for an example of the compiler complaint. cppregex.cpp C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530): warning C4774: '_scprintf' : format string expected in argument 1 is not a string literal C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530): note: e.g. instead of printf(name); use printf("%s", name); because format specifiers in 'name' may pose a security issue C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530): note: consider using constexpr specifier for named string literals C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(583): note: see reference to function template instantiation 'std::string std::_Floating_to_string(const char *,_Ty)' being compiled with [ _Ty=float ] --- diff --git a/include/extern.h b/include/extern.h index 7b0f65e78..17a116310 100644 --- a/include/extern.h +++ b/include/extern.h @@ -748,7 +748,7 @@ extern void explode(int, int, int, int, char, int); extern long scatter(int, int, int, unsigned int, struct obj *); extern void splatter_burning_oil(int, int, boolean); extern void explode_oil(struct obj *, int, int); -extern int adtyp_to_expltype(int); +extern int adtyp_to_expltype(const int); extern void mon_explodes(struct monst *, struct attack *); /* ### extralev.c ### */ diff --git a/sys/windows/Makefile.msc b/sys/windows/Makefile.msc index 37bc1072a..fa163272e 100644 --- a/sys/windows/Makefile.msc +++ b/sys/windows/Makefile.msc @@ -100,7 +100,7 @@ GAMEDIR = ..\binary # Default game build directory # of your PDCurses C files. # #ADD_CURSES=Y -#PDCURSES_TOP=..\lib\pdcurses +#PDCURSES_TOP=..\lib\pdcursesmod # #------------------------------------------------------------------------------ # OPTIONAL - zlib support (to allow compressed savefile exchange across platforms @@ -658,22 +658,22 @@ lcommon= /NOLOGO /INCREMENTAL:NO !IF "$(DEBUGINFO)" == "Y" ldebug = /DEBUG -cflags1=$(ccommon) $(cdebug) +ctmpflags1=$(ccommon) $(cdebug) lflags1=$(lcommon) $(ldebug) !ELSE ldebug= /DEBUG -cflags1=$(ccommon) $(crelease) +ctmpflags1=$(ccommon) $(crelease) lflags1=$(lcommon) $(ldebug) !ENDIF lflags= $(lflags1) !IF "$(TARGET_CPU)" == "x86" -cflags = $(cflags1) -D_X86_=1 -DWIN32 -D_WIN32 -W3 +ctmpflags = $(ctmpflags1) -D_X86_=1 -DWIN32 -D_WIN32 -W3 scall = -Gz !ELSEIF "$(TARGET_CPU)" == "x64" -cflags = $(cflags1) -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 +ctmpflags = $(ctmpflags1) -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 scall = !ENDIF @@ -689,7 +689,9 @@ scall = # 4777 format string requires an argument of type ‘type’, # but variadic argument ‘position’ has type ‘type’ # 4820 padding in struct -cflags = $(cflags:-W3=-W4) -wd4100 -wd4244 -wd4245 -wd4310 -wd4706 -w44774 -w44777 -wd4820 +ctmpflags = $(ctmpflags:-W3=-W4) -wd4100 -wd4244 -wd4245 -wd4310 -wd4706 -w44777 -wd4820 +cppflags = $(ctmpflags) +cflags = $(ctmpflags) -w44774 !ENDIF #More verbose warning output options below @@ -734,6 +736,7 @@ INCLDIR= /I..\include /I..\sys\windows $(LUAINCL) #========================================== cflagsBuild = $(cflags) $(INCLDIR) $(WINPFLAG) $(DLBFLG) -DSAFEPROCS +cppflagsBuild = $(cppflags) $(INCLDIR) $(WINPFLAG) $(DLBFLG) -DSAFEPROCS lflagsBuild = $(lflags) $(conlibs) $(MACHINE) #========================================== @@ -772,7 +775,7 @@ DLB = @$(cc) $(cflagsBuild) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ $< {$(SSYS)}.cpp{$(OBJ)}.o: - @$(cc) $(cflagsBuild) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) /EHsc -Fo$@ $< + @$(cc) $(cppflagsBuild) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) /EHsc -Fo$@ $< #========================================== # Rules for files in sys\windows