From fbcabcf68989c97594aa6bb5b44971d2e32dcc28 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 12 Sep 2023 08:02:24 +0100 Subject: [PATCH] Add an option to avoid wchar APIs on Windows With this, fmt can be used on Windows 98 and the Original Xbox with: set(FMT_OS OFF) `FMT_WINDOWS_NO_WCHAR` is detected automatically in 2 cases: 1. Missing `` on the original Xbox 2. A defined `WINVER` on properly configured Windows projects In other cases, one can `add_definitions(FMT_WINDOWS_NO_WCHAR)` in the fmt subproject. Fixes #3631 --- include/fmt/format-inl.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 553e7ce88d4b..c7e119a79c81 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -18,9 +18,18 @@ # include #endif +#include "core.h" + #ifdef _WIN32 +#if !defined(FMT_WINDOWS_NO_WCHAR) && (!FMT_HAS_INCLUDE() || (defined(WINVER) && WINVER <= 0x0500 && !defined(_WIN32_WINNT))) +// A legacy Windows platform without wide char APIs, e.g. Windows 98, original Xbox. +#define FMT_WINDOWS_NO_WCHAR +#endif + +#ifndef FMT_WINDOWS_NO_WCHAR # include // _isatty #endif +#endif #include "format.h" @@ -1426,7 +1435,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;