From adbd67fc6ce0fd0f4b7db395818429ec28d4cd41 Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Tue, 19 Jul 2022 08:10:47 +0200 Subject: [PATCH] Encode ABI information in inline namespace Add _diag suffix to inline namespace if JSON_DIAGNOSTICS is enabled, and _ldvcmp suffix if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON is enabled. --- include/nlohmann/detail/macro_scope.hpp | 19 +++++++++++++------ single_include/nlohmann/json.hpp | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 4f7c88f07..4e3f6e7f7 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -256,13 +256,20 @@ #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS #endif +#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp +#else + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON +#endif + #define NLOHMANN_JSON_ABI_PREFIX json_v3_10_5 -#define NLOHMANN_JSON_ABI_CONCAT_EX(a, b) a ## b -#define NLOHMANN_JSON_ABI_CONCAT(a, b) NLOHMANN_JSON_ABI_CONCAT_EX(a, b) -#define NLOHMANN_JSON_ABI_STRING \ - NLOHMANN_JSON_ABI_CONCAT( \ - NLOHMANN_JSON_ABI_PREFIX, \ - NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS \ +#define NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c) a ## b ## c +#define NLOHMANN_JSON_ABI_CONCAT(a, b, c) NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c) +#define NLOHMANN_JSON_ABI_STRING \ + NLOHMANN_JSON_ABI_CONCAT( \ + NLOHMANN_JSON_ABI_PREFIX, \ + NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ + NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON \ ) #define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_ABI_STRING diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 11f9d0978..c7ef032c7 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2517,13 +2517,20 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS #endif +#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp +#else + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON +#endif + #define NLOHMANN_JSON_ABI_PREFIX json_v3_10_5 -#define NLOHMANN_JSON_ABI_CONCAT_EX(a, b) a ## b -#define NLOHMANN_JSON_ABI_CONCAT(a, b) NLOHMANN_JSON_ABI_CONCAT_EX(a, b) -#define NLOHMANN_JSON_ABI_STRING \ - NLOHMANN_JSON_ABI_CONCAT( \ - NLOHMANN_JSON_ABI_PREFIX, \ - NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS \ +#define NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c) a ## b ## c +#define NLOHMANN_JSON_ABI_CONCAT(a, b, c) NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c) +#define NLOHMANN_JSON_ABI_STRING \ + NLOHMANN_JSON_ABI_CONCAT( \ + NLOHMANN_JSON_ABI_PREFIX, \ + NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ + NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON \ ) #define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_ABI_STRING