From a82712d220fc2df963c9a5463c77dd6d92ad7577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Tue, 2 Jan 2024 23:43:30 -0600 Subject: [PATCH] Restore symbol from 10.1 Fixes #3785. the write_console symbol has changed from 10.1 to 10.2. Here we restore the symbol as introduced in 10.1. --- include/fmt/format-inl.h | 5 +++++ include/fmt/format.h | 1 + 2 files changed, 6 insertions(+) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index e9a4ca453a8c..daeae5b1d9e4 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -1434,6 +1434,7 @@ FMT_FUNC auto vformat(string_view fmt, format_args args) -> std::string { namespace detail { #if !defined(_WIN32) || defined(FMT_WINDOWS_NO_WCHAR) FMT_FUNC auto write_console(int, string_view) -> bool { return false; } +FMT_FUNC auto write_console(std::FILE* f, string_view text) -> bool { return false; } #else using dword = conditional_t; extern "C" __declspec(dllimport) int __stdcall WriteConsoleW( // @@ -1444,6 +1445,10 @@ FMT_FUNC bool write_console(int fd, string_view text) { return WriteConsoleW(reinterpret_cast(_get_osfhandle(fd)), u16.c_str(), static_cast(u16.size()), nullptr, nullptr) != 0; } + +FMT_FUNC auto write_console(std::FILE* f, string_view text) -> bool { + return write_console(_fileno(f), text); +} #endif #ifdef _WIN32 diff --git a/include/fmt/format.h b/include/fmt/format.h index 97f0e1fb12e1..7637c8a0d068 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -999,6 +999,7 @@ struct is_contiguous> : std::true_type { FMT_END_EXPORT namespace detail { FMT_API auto write_console(int fd, string_view text) -> bool; +FMT_API auto write_console(std::FILE* f, string_view text) -> bool; FMT_API void print(std::FILE*, string_view); } // namespace detail