From d7d917139b23d33193d88813523511669841ecf5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 5 Apr 2016 17:03:17 +0200 Subject: [PATCH] Problem: including recent "zmq_utils.h" crashes gcc -pedantic jobs Problem: Recent deprecation of the "zmq_utils.h" header file caused pedantic compilations (including czmq) to fail because non-portable #warning is used. Solution: Limit the deprecation warnings to compilers known or assumed to support the "#pragma message" (GCC, MSVC, CLANG) and wrap with GCC directives to not treat these warnings as errors on paranoid builds. --- include/zmq_utils.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/include/zmq_utils.h b/include/zmq_utils.h index 58e9bea5..f29638d5 100644 --- a/include/zmq_utils.h +++ b/include/zmq_utils.h @@ -28,9 +28,21 @@ */ /* This file is deprecated, and all its functionality provided by zmq.h */ +/* Note that -Wpedantic compilation requires GCC to avoid using its custom + extensions such as #warning, hence the trick below. Also, pragmas for + warnings or other messages are not standard, not portable, and not all + compilers even have an equivalent concept. + So in the worst case, this include file is treated as silently empty. */ -#ifndef _MSC_VER -#warning(zmq_utils.h is deprecated.All its functionality is provided by zmq.h.) -#else -#pragma message("Warning: zmq_utils.h is deprecated. All its functionality is provided by zmq.h.") +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) || defined(_MSC_VER) +#if defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic push +#pragma GCC diagnostic warning "-Wcpp" +#pragma GCC diagnostic ignored "-Werror" +#pragma GCC diagnostic ignored "-Wall" +#endif +#pragma message("Warning: zmq_utils.h is deprecated. All its functionality is provided by zmq.h.") +#if defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic pop +#endif #endif