From 96fb38cf3b905f21a7b1fc33d88273a77b70eabf Mon Sep 17 00:00:00 2001 From: zm1060 Date: Mon, 16 Oct 2023 11:11:49 +0800 Subject: [PATCH] Fix error: 'WC_ERR_INVALID_CHARS' was not declared in this scope --- src/sysinfo.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sysinfo.cc b/src/sysinfo.cc index 5eb5b9bd84..bf7017c416 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -428,11 +428,14 @@ std::string GetSystemName() { #ifndef UNICODE str = std::string(hostname, DWCOUNT); #else +#ifndef WC_ERR_INVALID_CHARS +#define WC_ERR_INVALID_CHARS 0x00000080 +#endif // `WideCharToMultiByte` returns `0` when conversion fails. - int len = WideCharToMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, hostname, + int len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, hostname, DWCOUNT, NULL, 0, NULL, NULL); str.resize(len); - WideCharToMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, hostname, DWCOUNT, &str[0], + WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, hostname, DWCOUNT, &str[0], str.size(), NULL, NULL); #endif return str;