From 8a1ad0897461e32186ce0795dcef769ff530c711 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Thu, 20 Aug 2020 11:06:57 +0530 Subject: [PATCH] include/json: check MSVC before adding pragma warning directive * File changes: include/json/{config.h, writer.h} * Summary: previously JSONCPP_DISABLE_DLL_INTERFACE_WARNING is defined when _MSC_VER or __MINGW32__ defined. So, when compiled with GCC or Clang using MinGW toolchain those #pragma warnings are also enabled. This change enables those #pragma warnings only when MSVC is used i.e. only when _MSC_VER is defined. --- include/json/config.h | 7 +++++-- include/json/writer.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/json/config.h b/include/json/config.h index 6359273..20d69e2 100644 --- a/include/json/config.h +++ b/include/json/config.h @@ -34,7 +34,6 @@ #if defined(JSON_DLL_BUILD) #if defined(_MSC_VER) || defined(__MINGW32__) #define JSON_API __declspec(dllexport) -#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING #elif defined(__GNUC__) || defined(__clang__) #define JSON_API __attribute__((visibility("default"))) #endif // if defined(_MSC_VER) @@ -42,10 +41,14 @@ #elif defined(JSON_DLL) #if defined(_MSC_VER) || defined(__MINGW32__) #define JSON_API __declspec(dllimport) -#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING #endif // if defined(_MSC_VER) #endif // ifdef JSON_DLL_BUILD +// Disable MSVC specific compiler warnings +#if defined(_MSC_VER) +#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING +#endif + #if !defined(JSON_API) #define JSON_API #endif diff --git a/include/json/writer.h b/include/json/writer.h index fb0852a..3bff9c2 100644 --- a/include/json/writer.h +++ b/include/json/writer.h @@ -15,7 +15,7 @@ // Disable warning C4251: : needs to have dll-interface to // be used by... -#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) && defined(_MSC_VER) +#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) #pragma warning(push) #pragma warning(disable : 4251) #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)