From 30e542e52a801dfb64aac8de0fbcbf8e7fa30da1 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 7 Oct 2026 09:03:18 +0200 Subject: [PATCH] Declare the namespace-scope constants in to_chars.hpp inline (#5776) MSVC warns with C5260 that kAlpha and kGamma have internal linkage when the header is used as a header unit or through a module. JSON_INLINE_VARIABLE makes them inline variables from C++17 on. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/conversions/to_chars.hpp | 4 ++-- single_include/nlohmann/json.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp index c0945ab9e..52342db40 100644 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ b/include/nlohmann/detail/conversions/to_chars.hpp @@ -308,8 +308,8 @@ boundaries compute_boundaries(FloatType value) // // -e <= 60 or e >= -60 := alpha -constexpr int kAlpha = -60; -constexpr int kGamma = -32; +JSON_INLINE_VARIABLE constexpr int kAlpha = -60; +JSON_INLINE_VARIABLE constexpr int kGamma = -32; struct cached_power // c = f * 2^e ~= 10^k { diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index e56ebfbad..b7d344b72 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -24445,8 +24445,8 @@ boundaries compute_boundaries(FloatType value) // // -e <= 60 or e >= -60 := alpha -constexpr int kAlpha = -60; -constexpr int kGamma = -32; +JSON_INLINE_VARIABLE constexpr int kAlpha = -60; +JSON_INLINE_VARIABLE constexpr int kGamma = -32; struct cached_power // c = f * 2^e ~= 10^k {