From dda65b8fb01ac399af8fa44085db3cd9ab6cef2b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 28 Apr 2016 19:32:40 +0300 Subject: Add workaround for fix compilation warnings in SDL2. --- src/input/keyboardconfig.h | 8 ++++++++ src/localconsts.h | 37 ++++++++++++++++++++++--------------- src/logger.h | 8 ++++++++ src/net/sdltcpnet.h | 8 ++++++++ src/resources/screenshothelper.h | 8 ++++++++ src/soundmanager.h | 8 ++++++++ src/utils/physfsrwops.h | 8 ++++++++ src/utils/sdl2helper.h | 4 ++++ tools/ci/jobs/gccsnapshot_sdl2.sh | 2 +- 9 files changed, 75 insertions(+), 16 deletions(-) diff --git a/src/input/keyboardconfig.h b/src/input/keyboardconfig.h index a67101514..21b7ac608 100644 --- a/src/input/keyboardconfig.h +++ b/src/input/keyboardconfig.h @@ -23,6 +23,14 @@ #ifndef INPUT_KEYBOARDCONFIG_H #define INPUT_KEYBOARDCONFIG_H +#ifdef USE_SDL2 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-default" +#endif +#include +#ifdef USE_SDL2 +#pragma GCC diagnostic pop +#endif #include #include "sdlshared.h" diff --git a/src/localconsts.h b/src/localconsts.h index 96943671e..4f5358763 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -18,21 +18,6 @@ * along with this program. If not, see . */ -#include - -#if SDL_VERSION_ATLEAST(2, 0, 0) -#ifndef USE_SDL2 -#warning using SDL2 headers but configure set to use SDL1.2 -#warning please add configure flag --with-sdl2 -#define USE_SDL2 -#endif -#else -#ifdef USE_SDL2 -#error using SDL1.2 headers but configure set to use SDL2 -#error please remove configure flag --with-sdl2 -#endif -#endif - #define CAST_8 static_cast #define CAST_S8 static_cast #define CAST_U8 static_cast @@ -237,6 +222,28 @@ #endif // ENABLE_CHECKS +#ifdef USE_SDL2 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-default" +#endif +#include +#ifdef USE_SDL2 +#pragma GCC diagnostic pop +#endif + +#if SDL_VERSION_ATLEAST(2, 0, 0) +#ifndef USE_SDL2 +#warning using SDL2 headers but configure set to use SDL1.2 +#warning please add configure flag --with-sdl2 +#define USE_SDL2 +#endif +#else +#ifdef USE_SDL2 +#error using SDL1.2 headers but configure set to use SDL2 +#error please remove configure flag --with-sdl2 +#endif +#endif + // #define DEBUG_CONFIG 1 // #define DEBUG_BIND_TEXTURE 1 // #define DISABLE_RESOURCE_CACHING 1 diff --git a/src/logger.h b/src/logger.h index cdac1ffc5..abf2a72c1 100644 --- a/src/logger.h +++ b/src/logger.h @@ -25,6 +25,14 @@ #include "main.h" +#ifdef USE_SDL2 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-default" +#endif +#include +#ifdef USE_SDL2 +#pragma GCC diagnostic pop +#endif #include #include diff --git a/src/net/sdltcpnet.h b/src/net/sdltcpnet.h index be5879fb3..7d0a491c8 100644 --- a/src/net/sdltcpnet.h +++ b/src/net/sdltcpnet.h @@ -21,6 +21,14 @@ #ifndef NET_SDLTCPNET_H #define NET_SDLTCPNET_H +#ifdef USE_SDL2 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-default" +#endif +#include +#ifdef USE_SDL2 +#pragma GCC diagnostic pop +#endif #include #include "localconsts.h" diff --git a/src/resources/screenshothelper.h b/src/resources/screenshothelper.h index d74abfd73..6982c681a 100644 --- a/src/resources/screenshothelper.h +++ b/src/resources/screenshothelper.h @@ -23,6 +23,14 @@ #ifndef RESOURCES_SCREENSHOTHELPER_H #define RESOURCES_SCREENSHOTHELPER_H +#ifdef USE_SDL2 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-default" +#endif +#include +#ifdef USE_SDL2 +#pragma GCC diagnostic pop +#endif #include #include "localconsts.h" diff --git a/src/soundmanager.h b/src/soundmanager.h index a73975536..8de7b0dfa 100644 --- a/src/soundmanager.h +++ b/src/soundmanager.h @@ -23,6 +23,14 @@ #ifndef SOUNDMANAGER_H #define SOUNDMANAGER_H +#ifdef USE_SDL2 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-default" +#endif +#include +#ifdef USE_SDL2 +#pragma GCC diagnostic pop +#endif #include #include "listeners/configlistener.h" diff --git a/src/utils/physfsrwops.h b/src/utils/physfsrwops.h index 4c3c05988..e1226f3b4 100644 --- a/src/utils/physfsrwops.h +++ b/src/utils/physfsrwops.h @@ -25,6 +25,14 @@ #ifndef UTILS_PHYSFSRWOPS_H #define UTILS_PHYSFSRWOPS_H +#ifdef USE_SDL2 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-default" +#endif +#include +#ifdef USE_SDL2 +#pragma GCC diagnostic pop +#endif #include #include "utils/physfstools.h" diff --git a/src/utils/sdl2helper.h b/src/utils/sdl2helper.h index d1b918b51..7cf471542 100644 --- a/src/utils/sdl2helper.h +++ b/src/utils/sdl2helper.h @@ -24,6 +24,10 @@ #ifdef USE_SDL2 #include "utils/stringvector.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-default" +#include +#pragma GCC diagnostic pop #include #include "localconsts.h" diff --git a/tools/ci/jobs/gccsnapshot_sdl2.sh b/tools/ci/jobs/gccsnapshot_sdl2.sh index 1750e704a..6c80af066 100755 --- a/tools/ci/jobs/gccsnapshot_sdl2.sh +++ b/tools/ci/jobs/gccsnapshot_sdl2.sh @@ -14,7 +14,7 @@ aptget_install gcc-snapshot \ export CXXFLAGS="-pedantic -ggdb3 -O2 -pipe -Wstrict-aliasing=2 \ -Wstrict-overflow=1 -Wformat=1 -D_FORTIFY_SOURCE=2 \ --std=gnu++1z -Wformat=1 -Wno-switch-default" +-std=gnu++1z -Wformat=1" source ./tools/ci/flags/gccsnapshot.sh -- cgit v1.2.3-70-g09d2