From ab5cecb34feb18f5a030517547b0ead1148d05fc Mon Sep 17 00:00:00 2001 From: flagarde Date: Tue, 5 Apr 2022 02:45:19 +0800 Subject: [PATCH] Report the right __cplusplus value for MSVC in basic_json meta() (#3417) * Report the right __cplusplus value for MSVC in basic_json meta() * Run amalgamate --- include/nlohmann/json.hpp | 5 ++++- single_include/nlohmann/json.hpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 6bf77d507..496007c0d 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -310,7 +310,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; #endif -#ifdef __cplusplus + +#if defined(_MSVC_LANG) + result["compiler"]["c++"] = std::to_string(_MSVC_LANG); +#elif defined(__cplusplus) result["compiler"]["c++"] = std::to_string(__cplusplus); #else result["compiler"]["c++"] = "unknown"; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ba272a126..33a91164c 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -17505,7 +17505,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; #endif -#ifdef __cplusplus + +#if defined(_MSVC_LANG) + result["compiler"]["c++"] = std::to_string(_MSVC_LANG); +#elif defined(__cplusplus) result["compiler"]["c++"] = std::to_string(__cplusplus); #else result["compiler"]["c++"] = "unknown";