diff options
Diffstat (limited to 'ws_diag_control.h')
-rw-r--r-- | ws_diag_control.h | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/ws_diag_control.h b/ws_diag_control.h index b2a4561f6f..428091addd 100644 --- a/ws_diag_control.h +++ b/ws_diag_control.h @@ -24,6 +24,8 @@ #ifndef __WS_DIAG_CONTROL_H__ #define __WS_DIAG_CONTROL_H__ +#include "ws_compiler_tests.h" + #ifdef __cplusplus extern "C" { #endif @@ -45,26 +47,35 @@ extern "C" { pragma clang diagnostic error/warning/ignored -Wxxx and pragma clang diagnostic push/pop were introduced in clang 2.8 */ -#if defined(__GNUC__) && !defined(__clang__) -# define gcc_version ((__GNUC__ * 1000) + (__GNUC_MINOR__ * 10)) -# if gcc_version >= 4080 - /* - * gcc version is >= 4.8.0. We can use "GCC diagnostic push/pop" *and* - * gcc supports "-Wpedantic". - */ -# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x) -# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x)) -# define DIAG_ON(x) DIAG_PRAGMA(pop) -# endif -#elif defined(__clang__) -# define clang_version ((__clang_major__ * 1000) + (__clang_minor__ * 10)) -# if clang_version >= 2080 - /* clang version is >= 2.8: we can use "clang diagnostic ignored -Wxxx" - and "clang diagnostic push/pop" */ -# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x) -# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x)) -# define DIAG_ON(x) DIAG_PRAGMA(pop) -# endif +#if !defined(__clang__) && WS_IS_AT_LEAST_GNUC_VERSION(4,8) + /* + * This is GCC, or a compiler that 1) claims to be GCC and 2) does + * *not* claim to be Clang, and is claiming to be GCC version 4.8.0 + * or later. + * We can use "GCC diagnostic push/pop" *and* gcc supports "-Wpedantic". + */ + #define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x) + #define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x)) + #define DIAG_ON(x) DIAG_PRAGMA(pop) +#elif WS_IS_AT_LEAST_CLANG_VERSION(2,8) + /* + * This is Clang 2.8 or later: we can use "clang diagnostic ignored -Wxxx" + * and "clang diagnostic push/pop". + */ + #define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x) + #define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x)) + #define DIAG_ON(x) DIAG_PRAGMA(pop) +#else + /* + * This is none of the above; we don't have any way to turn diagnostics + * on or off. + * + * XXX - you can do that in MSVC, but it's done differently; we'd + * have to have macros for *particular* diagnostics, using the + * warning flag for GCC and Clang and the error number for MSVC. + */ + #define DIAG_OFF(x) + #define DIAG_ON(x) #endif /* Use for clang specific pragmas, so we can keep -Wpragmas enabled */ @@ -76,13 +87,6 @@ extern "C" { # define DIAG_ON_CLANG(x) #endif -#ifndef DIAG_OFF - /* no gcc or clang, or gcc version < 4.2.0, or clang version < 2.8: - we can't do anything */ -# define DIAG_OFF(x) -# define DIAG_ON(x) -#endif - /* * For dealing with APIs which are only deprecated in macOS (like the * OpenSSL and MIT/Heimdal Kerberos APIs). |