forked from nlohmann/json
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: move defines into separate header file
Move definition of common macros (e.g., JSON_HAS_CPP_*) into macros.hpp header file and update unit test sources. Incidentally enables the regression tests for nlohmann#2546 and nlohmann#3070. A CHECK_THROWS_WITH_AS in nlohmann#3070 was disabled, which is tracked here: nlohmann#337
- Loading branch information
1 parent
5bbad1e
commit 5a90ce3
Showing
5 changed files
with
87 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#pragma once | ||
|
||
// C++ language standard detection | ||
// if the user manually specified the used c++ version this is skipped | ||
#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) | ||
#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) | ||
#define JSON_HAS_CPP_20 | ||
#define JSON_HAS_CPP_17 | ||
#define JSON_HAS_CPP_14 | ||
#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 | ||
#define JSON_HAS_CPP_17 | ||
#define JSON_HAS_CPP_14 | ||
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) | ||
#define JSON_HAS_CPP_14 | ||
#endif | ||
// the cpp 11 flag is always specified because it is the minimal required version | ||
#define JSON_HAS_CPP_11 | ||
#endif | ||
|
||
#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) | ||
#ifdef JSON_HAS_CPP_17 | ||
#if defined(__cpp_lib_filesystem) | ||
#define JSON_HAS_FILESYSTEM 1 | ||
#elif defined(__cpp_lib_experimental_filesystem) | ||
#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 | ||
#elif !defined(__has_include) | ||
#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 | ||
#elif __has_include(<filesystem>) | ||
#define JSON_HAS_FILESYSTEM 1 | ||
#elif __has_include(<experimental/filesystem>) | ||
#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 | ||
#endif | ||
|
||
// std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ | ||
#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 | ||
#undef JSON_HAS_FILESYSTEM | ||
#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM | ||
#endif | ||
|
||
// no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support | ||
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 | ||
#undef JSON_HAS_FILESYSTEM | ||
#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM | ||
#endif | ||
|
||
// no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support | ||
#if defined(__clang_major__) && __clang_major__ < 7 | ||
#undef JSON_HAS_FILESYSTEM | ||
#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM | ||
#endif | ||
|
||
// no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support | ||
#if defined(_MSC_VER) && _MSC_VER < 1914 | ||
#undef JSON_HAS_FILESYSTEM | ||
#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM | ||
#endif | ||
|
||
// no filesystem support before iOS 13 | ||
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 | ||
#undef JSON_HAS_FILESYSTEM | ||
#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM | ||
#endif | ||
|
||
// no filesystem support before macOS Catalina | ||
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 | ||
#undef JSON_HAS_FILESYSTEM | ||
#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM | ||
#endif | ||
#endif | ||
#endif | ||
|
||
#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM | ||
#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 | ||
#endif | ||
|
||
#ifndef JSON_HAS_FILESYSTEM | ||
#define JSON_HAS_FILESYSTEM 0 | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters