DWORD is always a 32 bit unsigned integer. But "unsigned long" is sometimes a 32 or 64 bits...
This commit is contained in:
parent
fb58a7e8a2
commit
481660af60
@ -25,11 +25,20 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
FMT_BEGIN_NAMESPACE
|
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" {
|
extern "C" {
|
||||||
int __stdcall WriteConsoleW(void* hConsoleOutput, const void* lpBuffer,
|
int __stdcall WriteConsoleW(void* hConsoleOutput, const void* lpBuffer,
|
||||||
uint32_t nNumberOfCharsToWrite,
|
DWORD nNumberOfCharsToWrite,
|
||||||
uint32_t* lpNumberOfCharsWritten, void* lpReserved);
|
DWORD* lpNumberOfCharsWritten, void* lpReserved);
|
||||||
}
|
}
|
||||||
|
} // namespace details
|
||||||
FMT_END_NAMESPACE
|
FMT_END_NAMESPACE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2895,9 +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 = uint32_t();
|
auto written = details::DWORD();
|
||||||
if (!WriteConsoleW(reinterpret_cast<void*>(_get_osfhandle(fd)), u16.c_str(),
|
if (!details::WriteConsoleW(
|
||||||
static_cast<uint32_t>(u16.size()), &written, nullptr)) {
|
reinterpret_cast<void*>(_get_osfhandle(fd)), u16.c_str(),
|
||||||
|
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…
Reference in New Issue
Block a user