build warning fix on g++ >= 9 and Qt

../win/Qt/qt_menu.cpp: In member function ‘virtual void nethack_qt_::NetHackQtTextWindow::UseRIP(int, time_t)’:
../win/Qt/qt_menu.cpp:680:54: warning: ‘%s’ directive output may be truncated writing up to 31 bytes into a region of size 17 [-Wformat-truncation=]
  680 |     snprintf(rip_line[NAME_LINE], STONE_LINE_LEN+1, "%s", g.plname);
      |                                                      ^~   ~~~~~~~~
In file included from /usr/include/stdio.h:867,
                 from ../include/global.h:9,
                 from ../include/config.h:608,
                 from ../include/hack.h:10,
                 from ../win/Qt/qt_menu.cpp:8:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin_snprintf’ output between 1 and 32 bytes into a destination of size 17
   67 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~../win/Qt/qt_menu.cpp: In member function ‘virtual void nethack_qt_::NetHackQtTextWindow::UseRIP(int, time_t)’:
../win/Qt/qt_menu.cpp:680:54: warning: ‘%s’ directive output may be truncated writing up to 31 bytes into a region of size 17 [-Wformat-truncation=]
  680 |     snprintf(rip_line[NAME_LINE], STONE_LINE_LEN+1, "%s", g.plname);
      |                                                      ^~   ~~~~~~~~
In file included from /usr/include/stdio.h:867,
                 from ../include/global.h:9,
                 from ../include/config.h:608,
                 from ../include/hack.h:10,
                 from ../win/Qt/qt_menu.cpp:8:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:35: note: ‘__builtin_snprintf’ output between 1 and 32 bytes into a destination of size 17
   67 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
nhmall
2020-08-20 11:18:32 -04:00
parent d86dd4bb1b
commit e191e6bc8f
2 changed files with 14 additions and 0 deletions

View File

@@ -127,6 +127,13 @@ ifdef WANT_WIN_QT
# Qt5 requires C++11
LINK = $(CXX)
QTCXXFLAGS += -Wno-deprecated-declarations
ifeq "$(CCISCLANG)" ""
# get the version of g++
GPPGTEQ9 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 9)
ifeq "$(GPPGTEQ9)" "1"
QTCXXFLAGS+= -Wno-format-truncation
endif #g++ version greater than or equal to 9
endif #not clang
QTCXXFLAGS += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --cflags)
QTCXXFLAGS += -fPIC
WINLIB += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --libs)

View File

@@ -132,6 +132,13 @@ ifdef WANT_WIN_QT
# Qt5 requires C++11
LINK = $(CXX)
QTCXXFLAGS += -Wno-deprecated-declarations
ifeq "$(CCISCLANG)" ""
# get the version of g++
GPPGTEQ9 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 9)
ifeq "$(GPPGTEQ9)" "1"
QTCXXFLAGS+= -Wno-format-truncation
endif #g++ version greater than or equal to 9
endif #not clang
QTCXXFLAGS += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --cflags)
WINLIB += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --libs)
WINSRC += $(WINQTSRC)