From 31816bd2f66bf1db5aa34674fe383b628aca8c19 Mon Sep 17 00:00:00 2001 From: Orvid King <709247+Orvid@users.noreply.github.com> Date: Wed, 28 Dec 2022 16:59:02 -0800 Subject: [PATCH 1/2] Fix build with MSVC C++20 modules 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..f30b66daa7c1 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 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 && From d7f5d315961560458e94960a345437c223cb1134 Mon Sep 17 00:00:00 2001 From: Orvid King <709247+Orvid@users.noreply.github.com> Date: Wed, 28 Dec 2022 19:32:33 -0800 Subject: [PATCH 2/2] Update core.h --- include/fmt/core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index f30b66daa7c1..f194a4dc0df3 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -395,7 +395,7 @@ FMT_CONSTEXPR auto to_unsigned(Int value) -> return static_cast::type>(value); } -FMT_CONSTEXPR auto is_utf8() -> bool { +FMT_CONSTEXPR inline auto is_utf8() -> bool { FMT_MSC_WARNING(suppress : 4566) constexpr unsigned char section[] = "\u00A7"; // Avoid buggy sign extensions in MSVC's constant evaluation mode (#2297).