Skip to content

Commit

Permalink
Fix build with MSVC C++20 modules (#3254)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Orvid committed Dec 29, 2022
1 parent 9e60304 commit 7e5a959
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ FMT_CONSTEXPR auto to_unsigned(Int value) ->
return static_cast<typename std::make_unsigned<Int>::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 &&
Expand Down

0 comments on commit 7e5a959

Please sign in to comment.