diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index ff739f5d5..b414ec64d 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -50,7 +50,11 @@ #ifdef __has_include #if __has_include() #include + #elif __has_include() + #include #endif +#else + #include #endif #if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 85b3974ec..011a1d7b9 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -305,6 +305,17 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec result["compiler"]["c++"] = "unknown"; #endif + // see https://en.cppreference.com/w/cpp/header/ciso646 +#ifdef _LIBCPP_VERSION + result["compiler"]["libc++"] = {{"family", "LLVM libc++"}, {"version", _LIBCPP_VERSION}}; +#elif __GLIBCXX__ // Note: only version 6.1 or newer define this in ciso646 + result["compiler"]["libc++"] = {{"family", "GNU libstdc++"}, {"version", __GLIBCXX__}}; +#elif _CPPLIB_VER + result["compiler"]["libc++"] = {{"family", "Microsoft STL"}, {"version", _CPPLIB_VER}}; +#else + result["compiler"]["libc++"] = {{"family", "unknown"}, {"version", "unknown"}}; +#endif + // NOLINTBEGIN(modernize-use-bool-literals) result["config"]["JSON_DIAGNOSTICS"] = diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 0335565b9..1012196c4 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2379,7 +2379,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP #ifdef __has_include #if __has_include() #include + #elif __has_include() + #include #endif +#else + #include #endif #if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) @@ -19316,6 +19320,17 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec result["compiler"]["c++"] = "unknown"; #endif + // see https://en.cppreference.com/w/cpp/header/ciso646 +#ifdef _LIBCPP_VERSION + result["compiler"]["libc++"] = {{"family", "LLVM libc++"}, {"version", _LIBCPP_VERSION}}; +#elif __GLIBCXX__ // Note: only version 6.1 or newer define this in ciso646 + result["compiler"]["libc++"] = {{"family", "GNU libstdc++"}, {"version", __GLIBCXX__}}; +#elif _CPPLIB_VER + result["compiler"]["libc++"] = {{"family", "Microsoft STL"}, {"version", _CPPLIB_VER}}; +#else + result["compiler"]["libc++"] = {{"family", "unknown"}, {"version", "unknown"}}; +#endif + // NOLINTBEGIN(modernize-use-bool-literals) result["config"]["JSON_DIAGNOSTICS"] =