diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 553e7ce8..1ed7f198 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -18,7 +18,7 @@ # include #endif -#ifdef _WIN32 +#if defined(_WIN32) && !defined(FMT_WINDOWS_NO_WCHAR) # include // _isatty #endif @@ -1426,7 +1426,7 @@ FMT_FUNC std::string vformat(string_view fmt, format_args args) { } namespace detail { -#ifndef _WIN32 +#if !defined(_WIN32) || defined(FMT_WINDOWS_NO_WCHAR) FMT_FUNC bool write_console(std::FILE*, string_view) { return false; } #else using dword = conditional_t; @@ -1441,7 +1441,9 @@ FMT_FUNC bool write_console(std::FILE* f, string_view text) { return WriteConsoleW(reinterpret_cast(_get_osfhandle(fd)), u16.c_str(), static_cast(u16.size()), &written, nullptr) != 0; } +#endif +#ifdef _WIN32 // Print assuming legacy (non-Unicode) encoding. FMT_FUNC void vprint_mojibake(std::FILE* f, string_view fmt, format_args args) { auto buffer = memory_buffer(); diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index 1c468b43..4d6198b6 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -351,7 +351,7 @@ TEST(format_impl_test, write_dragon_even) { if (!FMT_MSC_VERSION) EXPECT_EQ(s, "33554450"); } -#ifdef _WIN32 +#if defined(_WIN32) && !defined(FMT_WINDOWS_NO_WCHAR) # include TEST(format_impl_test, write_console_signature) {