From ce3e4266e4f0712b27563d079b7e7b6fd8013014 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 31 Dec 2020 17:21:49 +0100 Subject: Disable glib warnings in the code Though annoying, this avoids relying on special compiler flags to suppress them. --- .clang-format | 1 + .gitmodules | 3 --- benchmark/dict_bench.c | 3 +++ benchmark/tree_bench.c | 3 +++ benchmark/warnings.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 benchmark/warnings.h diff --git a/.clang-format b/.clang-format index dc17e38..4544618 100644 --- a/.clang-format +++ b/.clang-format @@ -22,4 +22,5 @@ StatementMacros: - ZIX_MALLOC_API - ZIX_PURE_API - ZIX_UNUSED + - _Pragma ... diff --git a/.gitmodules b/.gitmodules index b2babe7..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "waflib"] - path = waflib - url = ../autowaf.git diff --git a/benchmark/dict_bench.c b/benchmark/dict_bench.c index 23e2f55..5d849d6 100644 --- a/benchmark/dict_bench.c +++ b/benchmark/dict_bench.c @@ -15,12 +15,15 @@ */ #include "bench.h" +#include "warnings.h" #include "zix/chunk.h" #include "zix/common.h" #include "zix/hash.h" +ZIX_DISABLE_GLIB_WARNINGS #include +ZIX_RESTORE_WARNINGS #include #include diff --git a/benchmark/tree_bench.c b/benchmark/tree_bench.c index 4d1f30f..2ba7204 100644 --- a/benchmark/tree_bench.c +++ b/benchmark/tree_bench.c @@ -15,12 +15,15 @@ */ #include "bench.h" +#include "warnings.h" #include "zix/btree.h" #include "zix/common.h" #include "zix/tree.h" +ZIX_DISABLE_GLIB_WARNINGS #include +ZIX_RESTORE_WARNINGS #include #include diff --git a/benchmark/warnings.h b/benchmark/warnings.h new file mode 100644 index 0000000..cb3a618 --- /dev/null +++ b/benchmark/warnings.h @@ -0,0 +1,42 @@ +/* + Copyright 2020 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 WARNINGS_H +#define WARNINGS_H + +#if defined(__clang__) + +# define ZIX_DISABLE_GLIB_WARNINGS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdocumentation-unknown-command\"") \ + _Pragma("clang diagnostic ignored \"-Wdocumentation\"") + +# define ZIX_RESTORE_WARNINGS _Pragma("clang diagnostic pop") + +#elif defined(__GNUC__) + +# define ZIX_DISABLE_GLIB_WARNINGS _Pragma("GCC diagnostic push") + +# define ZIX_RESTORE_WARNINGS _Pragma("GCC diagnostic pop") + +#else + +# define ZIX_DISABLE_GLIB_WARNINGS +# define ZIX_RESTORE_WARNINGS + +#endif + +#endif // WARNINGS_H -- cgit v1.2.1