]> granicus.if.org Git - nethack/commitdiff
clear a number of Qt build warnings on linux related to compiler flags
authornhmall <nhmall@nethack.org>
Wed, 3 Feb 2021 18:18:43 +0000 (13:18 -0500)
committernhmall <nhmall@nethack.org>
Wed, 3 Feb 2021 18:18:43 +0000 (13:18 -0500)
option ‘-Wimplicit’ is valid for C/ObjC but not for C++
option ‘-Wimplicit-function-declaration’ is valid for C/ObjC but not for C++
option ‘-Wimplicit-int’ is valid for C/ObjC but not for C++
option ‘-Wmissing-prototypes’ is valid for C/ObjC but not for C++
option ‘-Wmissing-parameter-type’ is valid for C/ObjC but not for C++
option ‘-Wold-style-definition’ is valid for C/ObjC but not for C++
option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++

include/warnings.h
sys/unix/Makefile.src
sys/unix/hints/include/compiler.2020

index f0cab3de44e4cc92e7a3c193c46f1cb0fa59019f..a1809a9a95c96e496046170cf63742238aa317b1 100644 (file)
 #define ACTIVATE_WARNING_PRAGMAS
 #endif
 #endif
-#if defined(__clang__) && defined(__cplusplus)
+#if defined(__GNUC__) || defined(__clang__)
+#if defined(__cplusplus)
 #ifndef ACTIVATE_WARNING_PRAGMAS
 #define ACTIVATE_WARNING_PRAGMAS
 #endif
-#endif
+#endif /* __cplusplus */
+#endif /* __GNUC__ || __clang__ */
 
 #ifdef ACTIVATE_WARNING_PRAGMAS
 #if defined(__clang__)
@@ -89,6 +91,7 @@
 #endif /* DISABLE_WARNING_PRAGMAS */
 
 #if !defined(STDC_Pragma_AVAILABLE)
+#error not good
 #define DISABLE_WARNING_UNREACHABLE_CODE
 #define DISABLE_WARNING_FORMAT_NONLITERAL
 #define DISABLE_WARNING_CONDEXPR_IS_CONSTANT
index 415b404c20be48efb1c7d200cd4e551ace09fe43..3c47316fc2da8ef0bc2a4badc8794f807be84dae 100644 (file)
@@ -176,7 +176,7 @@ SYSOBJ = $(TARGETPFX)ioctl.o $(TARGETPFX)unixmain.o $(TARGETPFX)unixtty.o \
 # The Qt and Be window systems are written in C++, while the rest of
 # NetHack is standard C.  If using Qt, uncomment the LINK line here to get
 # the C++ libraries linked in.
-CXXFLAGS = $(CFLAGS) -I. -I$(QTDIR)/include $(QTCXXFLAGS)
+CXXFLAGS = -I. -I$(QTDIR)/include $(QTCXXFLAGS)
 CXX ?= g++
 MOC ?= moc
 #LINK=g++
index 07fca15c3074c8de512c4fb8c9373413de6dd7b4..3205c09e2a6489d4f9e729d687b48cf8de385ca5 100755 (executable)
@@ -27,32 +27,35 @@ endif
 #CXX=clang++ -std=gnu++11
 
 CFLAGS=$(CCFLAGS) -I../include -DNOTPARMDECL
-
-ifndef WANT_WIN_QT
-ifndef WANT_LIBNH
-#      these are normally used when compiling nethack's core
-#      but -ansi forces -std=c90 for C or -std=c++98 for C++;
-#      win/Qt/qt_*.cpp compiled with C++98 semantics trigger
-#In file included from .../qt5/include/QtCore/qglobal.h:105:
-#.../qt5/include/QtCore/qcompilerdetection.h:561:6:
-#  error Qt requires a C++11 compiler and yours does not seem to be that.
-#      so we suppress -ansi when the build includes Qt
-#CFLAGS+=-ansi -Wno-long-long
-#CFLAGS+=-std=c99
-#
-#LIBNH's winshim requires C99 for the way it is currently coded
-endif
-endif
-
-CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit \
+CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers \
        -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings
 CFLAGS+=-pedantic
+CFLAGS+=-Wmissing-declarations
+CFLAGS+=-Wformat-nonliteral
 CFLAGS+=-DGCC_WARN
+# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so
+# # leave it out by default.
+# #CFLAGS+=-Wunreachable-code
+# #
+#
+# the following are not allowed in C++
+CFLAGS+=-Wimplicit
 CFLAGS+=-Wimplicit-function-declaration
 CFLAGS+=-Wimplicit-int
-CFLAGS+=-Wmissing-declarations
 CFLAGS+=-Wmissing-prototypes
-CFLAGS+=-Wformat-nonliteral
+CFLAGS+=-Wold-style-definition
+CFLAGS+=-Wstrict-prototypes
+
+ifdef WANT_WIN_QT
+QTCXXFLAGS = -g -I../include -DNOTPARMDECL
+QTCXXFLAGS+=-Wall -Wextra -Wno-missing-field-initializers \
+        -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings
+QTCXXFLAGS+=-pedantic
+QTCXXFLAGS+=-Wmissing-declarations
+QTCXXFLAGS+=-Wformat-nonliteral
+QTCXXFLAGS+=-DGCC_WARN
+endif
+
 ifeq "$(CCISCLANG)" ""
 #gcc-specific here
 CFLAGS+=-Wmissing-parameter-type
@@ -62,15 +65,20 @@ ifeq "$(GCCGTEQ9)" "1"
 # flags present in gcc version greater than or equal to 9 can go here
 #CFLAGS+=-Wno-format-overflow
 endif  #gcc version greater than or equal to 9
+
+ifdef WANT_WIN_QT
+# get the version of g++
+GPPGTEQ9 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 9)
+ifeq "$(GPPGTEQ9)" "1"
+#QTCXXFLAGS+=-Wno-format-overflow
+endif  #g++ version greater than or equal to 9
+#QTCXXFLAGS+= -Wno-format-truncation
+QTCXXFLAGS+= -Wno-deprecated-copy
+endif  #WANT_WIN_QT
+
 else   # clang
 # clang-specific here
 endif  # clang
-# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so
-# leave it out by default.
-#CFLAGS+=-Wunreachable-code
-#
-CFLAGS+=-Wold-style-definition
-CFLAGS+=-Wstrict-prototypes
 
 #end of compiler.2020
 #------------------------------------------------------------------------------