From db472075a4fb82bf6a491848941a5b9c92526c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 4 Oct 2020 14:30:35 +0200 Subject: Enable -Wcast-qual compiler warning --- Macros.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Macros.h') diff --git a/Macros.h b/Macros.h index 33e727d8..bb3a90e0 100644 --- a/Macros.h +++ b/Macros.h @@ -33,4 +33,20 @@ #endif /* __GNUC__ */ +// ignore casts discarding const specifier, e.g. +// const char [] -> char * / void * +// const char *[2]' -> char *const * +#ifdef __clang__ +#define IGNORE_WCASTQUAL_BEGIN _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#define IGNORE_WCASTQUAL_END _Pragma("clang diagnostic pop") +#elif defined(__GNUC__) +#define IGNORE_WCASTQUAL_BEGIN _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#define IGNORE_WCASTQUAL_END _Pragma("GCC diagnostic pop") +#else +#define IGNORE_WCASTQUAL_BEGIN +#define IGNORE_WCASTQUAL_END +#endif + #endif -- cgit v1.2.3