From a25ce7e9b8838c8e341c409aa85d44b55b448239 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 11 Jan 2021 05:40:31 +0100 Subject: Suppress Gtk and Qt header warnings in code --- src/cocoa_in_gtk2.mm | 3 +++ src/gtk2_in_qt5.cpp | 5 ++++ src/qt5_in_gtk.cpp | 7 +++++ src/warnings.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/win_in_gtk2.cpp | 3 +++ src/x11_in_gtk2.c | 4 +++ src/x11_in_gtk3.c | 4 +++ src/x11_in_qt5.cpp | 3 +++ wscript | 2 -- 9 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 src/warnings.h diff --git a/src/cocoa_in_gtk2.mm b/src/cocoa_in_gtk2.mm index d940d87..0bf9fe7 100644 --- a/src/cocoa_in_gtk2.mm +++ b/src/cocoa_in_gtk2.mm @@ -16,12 +16,15 @@ */ #include "suil_internal.h" +#include "warnings.h" #include "lv2/options/options.h" #include "lv2/urid/urid.h" +SUIL_DISABLE_GTK_WARNINGS #include #include +SUIL_RESTORE_WARNINGS #include diff --git a/src/gtk2_in_qt5.cpp b/src/gtk2_in_qt5.cpp index ce32c10..69b4dce 100644 --- a/src/gtk2_in_qt5.cpp +++ b/src/gtk2_in_qt5.cpp @@ -18,23 +18,28 @@ #include "dylib.h" #include "suil_config.h" // IWYU pragma: keep #include "suil_internal.h" +#include "warnings.h" #include "lv2/core/lv2.h" #include "suil/suil.h" +SUIL_DISABLE_QT_WARNINGS #include #include #include #include #include +SUIL_RESTORE_WARNINGS #undef signals +SUIL_DISABLE_GTK_WARNINGS #include #include #include #include #include +SUIL_RESTORE_WARNINGS #include diff --git a/src/qt5_in_gtk.cpp b/src/qt5_in_gtk.cpp index d657124..3699ae8 100644 --- a/src/qt5_in_gtk.cpp +++ b/src/qt5_in_gtk.cpp @@ -16,6 +16,7 @@ */ #include "suil_internal.h" +#include "warnings.h" #include "lv2/core/lv2.h" #include "lv2/options/options.h" @@ -23,14 +24,18 @@ #include "lv2/urid/urid.h" #include "suil/suil.h" +SUIL_DISABLE_QT_WARNINGS #include #include #include #include #include +SUIL_RESTORE_WARNINGS #undef signals +SUIL_DISABLE_GTK_WARNINGS + #include #include #include @@ -40,6 +45,8 @@ # include #endif +SUIL_RESTORE_WARNINGS + #include #include diff --git a/src/warnings.h b/src/warnings.h new file mode 100644 index 0000000..b7a03aa --- /dev/null +++ b/src/warnings.h @@ -0,0 +1,73 @@ +/* + Copyright 2021 David Robillard + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#ifndef SUIL_WARNINGS_H +#define SUIL_WARNINGS_H + +#if defined(__clang__) + +# define SUIL_DISABLE_GTK_WARNINGS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Weverything\"") + +# define SUIL_DISABLE_QT_WARNINGS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Weverything\"") + +# define SUIL_RESTORE_WARNINGS _Pragma("clang diagnostic pop") + +#elif defined(__GNUC__) + +# if defined(__cplusplus) +# define SUIL_DISABLE_GTK_WARNINGS \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \ + _Pragma("GCC diagnostic ignored \"-Wold-style-cast\"") \ + _Pragma("GCC diagnostic ignored \"-Wvolatile\"") \ + _Pragma("GCC diagnostic ignored \"-Wuseless-cast\"") +# else +# define SUIL_DISABLE_GTK_WARNINGS \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wc++-compat\"") \ + _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \ + _Pragma("GCC diagnostic ignored \"-Wstrict-prototypes\"") +# endif + +# define SUIL_DISABLE_QT_WARNINGS \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wconversion\"") \ + _Pragma("GCC diagnostic ignored \"-Wctor-dtor-privacy\"") \ + _Pragma("GCC diagnostic ignored \"-Weffc++\"") \ + _Pragma("GCC diagnostic ignored \"-Wmultiple-inheritance\"") \ + _Pragma("GCC diagnostic ignored \"-Wnoexcept\"") \ + _Pragma("GCC diagnostic ignored \"-Wredundant-tags\"") \ + _Pragma("GCC diagnostic ignored \"-Wsign-promo\"") \ + _Pragma("GCC diagnostic ignored \"-Wswitch-default\"") \ + _Pragma("GCC diagnostic ignored \"-Wabi-tag\"") \ + _Pragma("GCC diagnostic ignored \"-Wuseless-cast\"") + +# define SUIL_RESTORE_WARNINGS _Pragma("GCC diagnostic pop") + +#else + +# define SUIL_DISABLE_GTK_WARNINGS +# define SUIL_RESTORE_WARNINGS + +#endif + +#endif // SUIL_WARNINGS_H diff --git a/src/win_in_gtk2.cpp b/src/win_in_gtk2.cpp index 1a34dfa..14b82e8 100644 --- a/src/win_in_gtk2.cpp +++ b/src/win_in_gtk2.cpp @@ -15,12 +15,15 @@ */ #include "suil_internal.h" +#include "warnings.h" #include "lv2/options/options.h" #include "lv2/urid/urid.h" +SUIL_DISABLE_GTK_WARNINGS #include #include +SUIL_RESTORE_WARNINGS #ifndef WM_MOUSEWHEEL # define WM_MOUSEWHEEL 0x020A diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c index 4553132..80eef1a 100644 --- a/src/x11_in_gtk2.c +++ b/src/x11_in_gtk2.c @@ -15,6 +15,7 @@ */ #include "suil_internal.h" +#include "warnings.h" #include "lv2/core/lv2.h" #include "lv2/options/options.h" @@ -26,12 +27,15 @@ #include #include #include + +SUIL_DISABLE_GTK_WARNINGS #include #include #include #include #include #include +SUIL_RESTORE_WARNINGS #include #include diff --git a/src/x11_in_gtk3.c b/src/x11_in_gtk3.c index 04927d8..c93f3dd 100644 --- a/src/x11_in_gtk3.c +++ b/src/x11_in_gtk3.c @@ -15,6 +15,7 @@ */ #include "suil_internal.h" +#include "warnings.h" #include "lv2/core/lv2.h" #include "lv2/options/options.h" @@ -25,6 +26,8 @@ #include #include #include + +SUIL_DISABLE_GTK_WARNINGS #include #include #include @@ -32,6 +35,7 @@ #include #include #include +SUIL_RESTORE_WARNINGS #include #include diff --git a/src/x11_in_qt5.cpp b/src/x11_in_qt5.cpp index b8c3f18..ba7f036 100644 --- a/src/x11_in_qt5.cpp +++ b/src/x11_in_qt5.cpp @@ -16,11 +16,13 @@ */ #include "suil_internal.h" +#include "warnings.h" #include "lv2/core/lv2.h" #include "lv2/ui/ui.h" #include "suil/suil.h" +SUIL_DISABLE_QT_WARNINGS #include #include #include @@ -30,6 +32,7 @@ #include #include #include +SUIL_RESTORE_WARNINGS #include #include diff --git a/wscript b/wscript index 4de7e3e..1fbf185 100644 --- a/wscript +++ b/wscript @@ -71,11 +71,9 @@ def configure(conf): '-Wno-suggest-attribute=pure', ], 'clang': [ - '-Wno-atomic-implicit-seq-cst', '-Wno-cast-qual', '-Wno-disabled-macro-expansion', '-Wno-padded', - '-Wno-variadic-macros', ] }) -- cgit v1.2.1