Skip to content

Commit

Permalink
Add an option to avoid wchar APIs on Windows
Browse files Browse the repository at this point in the history
With this, fmt can be used on Windows 98 and the Original Xbox with:

    set(FMT_OS OFF)
    set(FMT_WINDOWS_NO_WCHAR ON)

Fixes fmtlib#3631
  • Loading branch information
glebm committed Sep 17, 2023
1 parent d498754 commit 82dce14
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@
# include <locale>
#endif

#ifdef _WIN32
#if defined(_WIN32)

// A legacy Windows platform without wide char APIs, e.g. Windows 98, original Xbox:
#if !defined(FMT_WINDOWS_NO_WCHAR) && \
(!FMT_HAS_INCLUDE(<io.h>) || (defined(WINVER) && WINVER <= 0x0500 && !defined(_WIN32_WINNT)))
#define FMT_WINDOWS_NO_WCHAR
#endif

#ifndef FMT_WINDOWS_NO_WCHAR
# include <io.h> // _isatty
#endif
#endif

#include "format.h"

Expand Down Expand Up @@ -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<sizeof(long) == 4, unsigned long, unsigned>;
Expand Down

0 comments on commit 82dce14

Please sign in to comment.