Skip to content

Commit 240c85a

Browse files
committed
MSVC warning fixes in tests
- only use "#pragma GCC" on GCC-compatible compilers - suppress deprecation warnings also on MSVC
1 parent d61cdde commit 240c85a

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/jsontestrunner/main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
// recognized in your jurisdiction.
44
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
55

6+
#if defined(__GNUC__)
67
#pragma GCC diagnostic push
78
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
9+
#elif defined(_MSC_VER)
10+
#pragma warning(disable : 4996)
11+
#endif
812

913
/* This executable is used for testing parser/writer using real JSON files.
1014
*/
@@ -14,10 +18,6 @@
1418
#include <sstream>
1519
#include <stdio.h>
1620

17-
#if defined(_MSC_VER) && _MSC_VER >= 1310
18-
#pragma warning(disable : 4996) // disable fopen deprecation warning
19-
#endif
20-
2121
struct Options
2222
{
2323
JSONCPP_STRING path;
@@ -328,4 +328,6 @@ int main(int argc, const char* argv[]) {
328328
}
329329
}
330330

331+
#if defined(__GNUC__)
331332
#pragma GCC diagnostic pop
333+
#endif

src/test_lib_json/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
// recognized in your jurisdiction.
44
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
55

6+
#if defined(__GNUC__)
67
#pragma GCC diagnostic push
78
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
9+
#elif defined(_MSC_VER)
10+
#pragma warning(disable : 4996)
11+
#endif
812

913
#include "jsontest.h"
1014
#include <json/config.h>
@@ -2591,4 +2595,6 @@ int main(int argc, const char* argv[]) {
25912595
return runner.runCommandLine(argc, argv);
25922596
}
25932597

2598+
#if defined(__GNUC__)
25942599
#pragma GCC diagnostic pop
2600+
#endif

0 commit comments

Comments
 (0)