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.
This commit is contained in:
Biswapriyo Nath 2020-08-20 11:06:57 +05:30
parent 5be07bdc5e
commit 8a1ad08974
2 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -15,7 +15,7 @@
// Disable warning C4251: <data member>: <type> 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)