From 63a2a7d9bf8d3a5c479dea400ca334720a30f32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Fri, 15 Dec 2017 11:32:32 +0100 Subject: [PATCH] lib/pragmas.h: Define for controlling compiler warning options --- lib/pragmas.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 lib/pragmas.h diff --git a/lib/pragmas.h b/lib/pragmas.h new file mode 100644 index 000000000..459245dd1 --- /dev/null +++ b/lib/pragmas.h @@ -0,0 +1,54 @@ +/* Defines for controlling compiler warnings + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef PRAGMAS_H_ +# define PRAGMAS_H_ 1 + +/* file local stringify, undef'ed after use */ +#define GL_STRINGIFY(a) #a + +#if defined __clang__ + +# define NOWARN(a) _Pragma( GL_STRINGIFY( clang diagnostic ignored a ) ) +# define NOWARN_PUSH(a) \ + _Pragma( GL_STRINGIFY( clang diagnostic push ) ) \ + _Pragma( GL_STRINGIFY( clang diagnostic ignored a ) ) +# define NOWARN_POP _Pragma( GL_STRINGIFY( gcc diagnostic pop ) ) + + /* clang complains about unknown options in diagnostic pragmas, + gcc doesn't. */ + NOWARN("-Wunknown-warning-option") + +#elif defined __GNUC__ && ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 5 ) ) + +# define NOWARN(a) _Pragma( GL_STRINGIFY( gcc diagnostic ignored a ) ) +# define NOWARN_PUSH(a) \ + _Pragma( GL_STRINGIFY( gcc diagnostic push ) ) \ + _Pragma( GL_STRINGIFY( gcc diagnostic ignored a ) ) +# define NOWARN_POP _Pragma( GL_STRINGIFY( gcc diagnostic pop ) ) + +#else + +# define NOWARN(a) +# define NOWARN_PUSH(a) +# define NOWARN_POP + +#endif + +#undef GL_STRINGIFY + +#endif /* PRAGMAS_H_ */ -- 2.15.1