mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-30 15:32:36 +00:00
Remove dependency on windows.h (#1900)
This commit is contained in:
parent
c156093ffd
commit
253d63159f
@ -23,16 +23,23 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# if defined(FMT_BIG_WIN) || defined(NOMINMAX)
|
|
||||||
# include <windows.h>
|
|
||||||
# else
|
|
||||||
# define NOMINMAX
|
|
||||||
# define WIN32_LEAN_AND_MEAN
|
|
||||||
# include <windows.h>
|
|
||||||
# undef WIN32_LEAN_AND_MEAN
|
|
||||||
# undef NOMINMAX
|
|
||||||
# endif
|
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
|
FMT_BEGIN_NAMESPACE
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
# if !defined(__LP64__)
|
||||||
|
using DWORD = unsigned long;
|
||||||
|
# else
|
||||||
|
using DWORD = unsigned int;
|
||||||
|
# endif
|
||||||
|
// WriteConsoleW should not become visible in global namespace
|
||||||
|
extern "C" {
|
||||||
|
int __stdcall WriteConsoleW(void* hConsoleOutput, const void* lpBuffer,
|
||||||
|
DWORD nNumberOfCharsToWrite,
|
||||||
|
DWORD* lpNumberOfCharsWritten, void* lpReserved);
|
||||||
|
}
|
||||||
|
} // namespace details
|
||||||
|
FMT_END_NAMESPACE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Dummy implementations of strerror_r and strerror_s called if corresponding
|
// Dummy implementations of strerror_r and strerror_s called if corresponding
|
||||||
@ -2897,10 +2904,10 @@ FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) {
|
|||||||
auto fd = _fileno(f);
|
auto fd = _fileno(f);
|
||||||
if (_isatty(fd)) {
|
if (_isatty(fd)) {
|
||||||
detail::utf8_to_utf16 u16(string_view(buffer.data(), buffer.size()));
|
detail::utf8_to_utf16 u16(string_view(buffer.data(), buffer.size()));
|
||||||
auto written = DWORD();
|
auto written = details::DWORD();
|
||||||
if (!WriteConsoleW(reinterpret_cast<HANDLE>(_get_osfhandle(fd)),
|
if (!details::WriteConsoleW(
|
||||||
u16.c_str(), static_cast<DWORD>(u16.size()), &written,
|
reinterpret_cast<void*>(_get_osfhandle(fd)), u16.c_str(),
|
||||||
nullptr)) {
|
static_cast<details::DWORD>(u16.size()), &written, nullptr)) {
|
||||||
FMT_THROW(format_error("failed to write to console"));
|
FMT_THROW(format_error("failed to write to console"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user