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
|
||||
# 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,
|
||||
uint32_t nNumberOfCharsToWrite,
|
||||
uint32_t* lpNumberOfCharsWritten, void* lpReserved);
|
||||
DWORD nNumberOfCharsToWrite,
|
||||
DWORD* lpNumberOfCharsWritten, void* lpReserved);
|
||||
}
|
||||
} // namespace details
|
||||
FMT_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
@ -2895,9 +2904,10 @@ FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) {
|
||||
auto fd = _fileno(f);
|
||||
if (_isatty(fd)) {
|
||||
detail::utf8_to_utf16 u16(string_view(buffer.data(), buffer.size()));
|
||||
auto written = uint32_t();
|
||||
if (!WriteConsoleW(reinterpret_cast<void*>(_get_osfhandle(fd)), u16.c_str(),
|
||||
static_cast<uint32_t>(u16.size()), &written, nullptr)) {
|
||||
auto written = details::DWORD();
|
||||
if (!details::WriteConsoleW(
|
||||
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"));
|
||||
}
|
||||
return;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user