From 30712fa758c0a3b77914e1f13ca67af9720d5a40 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 9 Oct 2026 23:51:24 +0200 Subject: [PATCH] Do not force-inline the view's functions on MSVC __forceinline makes MSVC report C4714 for function templates it cannot inline (get), an error under /WX. The forced inlining is only a performance hint, so use plain inline there. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/view/macro_scope.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/nlohmann/detail/view/macro_scope.hpp b/include/nlohmann/detail/view/macro_scope.hpp index 8bbae1970..e4b685094 100644 --- a/include/nlohmann/detail/view/macro_scope.hpp +++ b/include/nlohmann/detail/view/macro_scope.hpp @@ -28,7 +28,10 @@ #elif defined(_MSC_VER) #define NLOHMANN_VIEW_LIKELY(x) (x) #define NLOHMANN_VIEW_UNLIKELY(x) (x) - #define NLOHMANN_VIEW_ALWAYS_INLINE __forceinline + // plain inline: __forceinline makes MSVC report C4714 (not inlined) for + // function templates it cannot inline, which is an error under /WX; the + // forced inlining is only a performance hint + #define NLOHMANN_VIEW_ALWAYS_INLINE inline #define NLOHMANN_VIEW_NOINLINE __declspec(noinline) #else #define NLOHMANN_VIEW_LIKELY(x) (x)