Fix GCC module build and MSVC C4127 in the json_view SIMD code

GCC ignores the target attribute in modules, so the SSSE3 dispatch is
disabled for the module interface (the check stays portable, SSE2 is kept).
Make the 8-vs-16 byte unrolling condition in scan_string_run a
preprocessor/template split to avoid a constant condition (C4127).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-08 16:23:21 +02:00
1 parent ad715372bf
commit 9c7eb12918
5 files changed
+20 -4

No files matched your search

+6
View File
@@ -17,6 +17,12 @@ module;
// 3. Or upgrade to a newer GCC version with better modules support.
// See: https://github.com/nlohmann/json/issues/5103
// GCC ignores the target attribute in modules ("'target' attribute currently
// unsupported in modules") and then rejects the SSSE3 intrinsics of json_view.
#if defined(__GNUC__) && !defined(__clang__)
#define NLOHMANN_VIEW_NO_TARGET_ATTRIBUTE
#endif
#include <nlohmann/json.hpp>
#include <nlohmann/json_literals.hpp>
#include <nlohmann/json_view.hpp>