Repository navigation
Declare the namespace-scope constants in to_chars.hpp inline - #5776
Merged
Merged
Conversation
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 <mail@nlohmann.me>
nlohmann
force-pushed
the
fix-c5260-inline-constexpr
branch
from
October 7, 2026 07:01
f04d147 to
079b83b
Compare
nlohmann
added this pull request to stack #5778
October 7, 2026 07:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MSVC reports warning C5260 ("the constant variable … has internal linkage in an included header file context, but external linkage in imported header unit context") for
to_chars.hppwhen the library is used as a header unit or through a module, see #4826.The warning comes from
kAlphaandkGamma, the onlyconstexprvariables at namespace scope in that file. The other constants there are function-local or static members. This declares the two constantsJSON_INLINE_VARIABLE constexpr, which the library already uses forstatic_const. It expands toinlinefrom C++17 on and to nothing before, so C++11 and C++14 are unchanged.Not verified on MSVC locally. Checked with Apple Clang at C++11, C++17, and C++20 for both headers (
-Wall -Wextra -Werror, dumping floating-point numbers).API impact
No breaking changes. The two constants are in
nlohmann::detail::dtoa_impland keep their values.Written by Claude Code.
🤖 Generated with Claude Code