From 7e5a9595648f4643cd81eed83792ca93bf3b75c3 Mon Sep 17 00:00:00 2001 From: Orvid King <709247+Orvid@users.noreply.github.com> Date: Wed, 28 Dec 2022 19:58:57 -0800 Subject: [PATCH] Fix build with MSVC C++20 modules (#3254) When using fmt with C++20 modules under MSVC, it can end up requiring certain things to have storage that would not otherwise have needed to. Since I didn't see anything that was already doing detection for `inline constexpr` variable support, I've just moved the entire thing into the only function where it's used. --- include/fmt/core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index be0b6a880798..f194a4dc0df3 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -395,9 +395,9 @@ FMT_CONSTEXPR auto to_unsigned(Int value) -> return static_cast::type>(value); } -FMT_MSC_WARNING(suppress : 4566) constexpr unsigned char section[] = "\u00A7"; +FMT_CONSTEXPR inline auto is_utf8() -> bool { + FMT_MSC_WARNING(suppress : 4566) constexpr unsigned char section[] = "\u00A7"; -constexpr auto is_utf8() -> bool { // Avoid buggy sign extensions in MSVC's constant evaluation mode (#2297). using uchar = unsigned char; return FMT_UNICODE || (sizeof(section) == 3 && uchar(section[0]) == 0xC2 &&