Skip to content

Commit 016e804

Browse files
committed
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 both _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 #prgma warnings when only MSVC is used i.e. only _MSC_VER is defined.
1 parent 5be07bd commit 016e804

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

include/json/config.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,21 @@
3434
#if defined(JSON_DLL_BUILD)
3535
#if defined(_MSC_VER) || defined(__MINGW32__)
3636
#define JSON_API __declspec(dllexport)
37-
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
3837
#elif defined(__GNUC__) || defined(__clang__)
3938
#define JSON_API __attribute__((visibility("default")))
4039
#endif // if defined(_MSC_VER)
4140

4241
#elif defined(JSON_DLL)
4342
#if defined(_MSC_VER) || defined(__MINGW32__)
4443
#define JSON_API __declspec(dllimport)
45-
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
4644
#endif // if defined(_MSC_VER)
4745
#endif // ifdef JSON_DLL_BUILD
4846

47+
// Disable MSVC specific compiler warnings
48+
#if defined(_MSC_VER)
49+
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
50+
#endif
51+
4952
#if !defined(JSON_API)
5053
#define JSON_API
5154
#endif

include/json/writer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
1717
// be used by...
18-
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) && defined(_MSC_VER)
18+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
1919
#pragma warning(push)
2020
#pragma warning(disable : 4251)
2121
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)

0 commit comments

Comments
 (0)