diff --git a/cmake/download_test_data.cmake b/cmake/download_test_data.cmake index f516a7c3b..d2763147c 100644 --- a/cmake/download_test_data.cmake +++ b/cmake/download_test_data.cmake @@ -53,4 +53,4 @@ else() execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) endif() string(REGEX REPLACE "[ ]*\n" "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT}") -message(STATUS "Compiler: ${CXX_VERSION_RESULT}") +message(STATUS "Compiler: ${CXX_VERSION_RESULT}, ${CMAKE_CXX_COMPILE_FEATURES}") diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index 578a57c3e..5c79a67e5 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -19,7 +19,7 @@ #include #include -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL #if JSON_STD_FILESYSTEM_EXPERIMENTAL #include namespace nlohmann::detail @@ -460,7 +460,7 @@ void from_json(const BasicJsonType& j, std::unordered_map void from_json(const BasicJsonType& j, std_fs::path& p) { diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index f53b566e1..7fc5a05ef 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -15,7 +15,7 @@ #include #include -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL #if JSON_STD_FILESYSTEM_EXPERIMENTAL #include namespace nlohmann::detail @@ -403,7 +403,7 @@ void to_json(BasicJsonType& j, const T& t) to_json_tuple_impl(j, t, make_index_sequence::value> {}); } -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL template void to_json(BasicJsonType& j, const std_fs::path& p) { diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index f080db195..22c0ea525 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -52,6 +52,11 @@ #else #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 #endif + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if __MINGW32__ && __GNUC__ == 8 + #undef JSON_STD_FILESYSTEM_EXPERIMENTAL + #endif #endif // disable documentation warnings on clang diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 32dd5e1c6..7e758f05f 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2340,6 +2340,11 @@ using is_detected_convertible = #else #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 #endif + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if __MINGW32__ && __GNUC__ == 8 + #undef JSON_STD_FILESYSTEM_EXPERIMENTAL + #endif #endif // disable documentation warnings on clang @@ -3967,7 +3972,7 @@ T conditional_static_cast(U value) // #include -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL #if JSON_STD_FILESYSTEM_EXPERIMENTAL #include namespace nlohmann::detail @@ -4408,7 +4413,7 @@ void from_json(const BasicJsonType& j, std::unordered_map void from_json(const BasicJsonType& j, std_fs::path& p) { @@ -4655,7 +4660,7 @@ class tuple_element> // #include -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL #if JSON_STD_FILESYSTEM_EXPERIMENTAL #include namespace nlohmann::detail @@ -5043,7 +5048,7 @@ void to_json(BasicJsonType& j, const T& t) to_json_tuple_impl(j, t, make_index_sequence::value> {}); } -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL template void to_json(BasicJsonType& j, const std_fs::path& p) { diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 158e27748..807e27f14 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -62,6 +62,11 @@ using ordered_json = nlohmann::ordered_json; #define JSON_STD_FILESYSTEM_EXPERIMENTAL 1 #else #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if __MINGW32__ && __GNUC__ == 8 + #undef JSON_STD_FILESYSTEM_EXPERIMENTAL + #endif #endif #if JSON_STD_FILESYSTEM_EXPERIMENTAL @@ -379,9 +384,7 @@ TEST_CASE("regression tests 2") #ifdef JSON_HAS_CPP_17 SECTION("issue #1292 - Serializing std::variant causes stack overflow") { - static_assert( - !std::is_constructible>::value, - ""); + static_assert(!std::is_constructible>::value, "unexpected value"); } #endif @@ -756,7 +759,7 @@ TEST_CASE("regression tests 2") CHECK(j == k); } -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL SECTION("issue #3070 - Version 3.10.3 breaks backward-compatibility with 3.10.2 ") { nlohmann::detail::std_fs::path text_path("/tmp/text.txt");