]> granicus.if.org Git - nethack/commitdiff
fix some VS warnings that recently appeared
authornhmall <nhmall@nethack.org>
Sat, 14 Aug 2021 19:36:54 +0000 (15:36 -0400)
committernhmall <nhmall@nethack.org>
Sat, 14 Aug 2021 19:36:54 +0000 (15:36 -0400)
  ..\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<float>(const char *,_Ty)' being compiled
          with
[
   _Ty=float
]

include/extern.h
sys/windows/Makefile.msc

index 7b0f65e788a9edaa313875127f150655b572b1c4..17a116310c5221c758387601796cf8122670896a 100644 (file)
@@ -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 ### */
index 37bc1072a102116205a1f2686a0d5dc7a6240783..fa163272e78ed70873354e2aeb922bf10614aad4 100644 (file)
@@ -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 \91type\92,
 #      but variadic argument \91position\92 has type \91type\92
 # 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