From 9855db81f317dd5dafc06e3c14ba198851802657 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 22 Oct 2026 08:40:05 +0200 Subject: [PATCH] Silence macro-to-enum for the endianness macros (#5881) #5876 added JSON_LITTLE_ENDIAN_TARGET and JSON_BIG_ENDIAN_TARGET to macro_scope.hpp. They must stay macros because they select code in #if, so suppress the clang-tidy check as simd_scan.hpp already does. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/macro_scope.hpp | 12 ++++++------ single_include/nlohmann/json.hpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 4b95fec43..061c48853 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -193,14 +193,14 @@ // handles the bytes one at a time); MSVC and x86 targets are little-endian #if defined(_MSC_VER) || defined(__x86_64__) || defined(__i386__) \ || (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - #define JSON_LITTLE_ENDIAN_TARGET 1 - #define JSON_BIG_ENDIAN_TARGET 0 + #define JSON_LITTLE_ENDIAN_TARGET 1 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) + #define JSON_BIG_ENDIAN_TARGET 0 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ - #define JSON_LITTLE_ENDIAN_TARGET 0 - #define JSON_BIG_ENDIAN_TARGET 1 + #define JSON_LITTLE_ENDIAN_TARGET 0 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) + #define JSON_BIG_ENDIAN_TARGET 1 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) #else - #define JSON_LITTLE_ENDIAN_TARGET 0 - #define JSON_BIG_ENDIAN_TARGET 0 + #define JSON_LITTLE_ENDIAN_TARGET 0 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) + #define JSON_BIG_ENDIAN_TARGET 0 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) #endif #ifdef JSON_HAS_CPP_17 diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 2c9cda422..89e89c12a 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2578,14 +2578,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP // handles the bytes one at a time); MSVC and x86 targets are little-endian #if defined(_MSC_VER) || defined(__x86_64__) || defined(__i386__) \ || (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - #define JSON_LITTLE_ENDIAN_TARGET 1 - #define JSON_BIG_ENDIAN_TARGET 0 + #define JSON_LITTLE_ENDIAN_TARGET 1 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) + #define JSON_BIG_ENDIAN_TARGET 0 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ - #define JSON_LITTLE_ENDIAN_TARGET 0 - #define JSON_BIG_ENDIAN_TARGET 1 + #define JSON_LITTLE_ENDIAN_TARGET 0 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) + #define JSON_BIG_ENDIAN_TARGET 1 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) #else - #define JSON_LITTLE_ENDIAN_TARGET 0 - #define JSON_BIG_ENDIAN_TARGET 0 + #define JSON_LITTLE_ENDIAN_TARGET 0 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) + #define JSON_BIG_ENDIAN_TARGET 0 // NOLINT(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum) #endif #ifdef JSON_HAS_CPP_17