From 335e4a316527b2640ec505c104c6efdcd5f5f80e Mon Sep 17 00:00:00 2001 From: zm1060 Date: Mon, 16 Oct 2023 09:48:35 +0800 Subject: [PATCH 1/3] Fix error: 'WC_ERR_INVALID_CHARS' was not declared in this scope --- src/sysinfo.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sysinfo.cc b/src/sysinfo.cc index 922e83ac92..5eb5b9bd84 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -429,10 +429,10 @@ std::string GetSystemName() { str = std::string(hostname, DWCOUNT); #else // `WideCharToMultiByte` returns `0` when conversion fails. - int len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, hostname, + int len = WideCharToMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, hostname, DWCOUNT, NULL, 0, NULL, NULL); str.resize(len); - WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, hostname, DWCOUNT, &str[0], + WideCharToMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, hostname, DWCOUNT, &str[0], str.size(), NULL, NULL); #endif return str; From 96fb38cf3b905f21a7b1fc33d88273a77b70eabf Mon Sep 17 00:00:00 2001 From: zm1060 Date: Mon, 16 Oct 2023 11:11:49 +0800 Subject: [PATCH 2/3] 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; From cb3330d2ec893853f08f9d1b86aef2230eee5a62 Mon Sep 17 00:00:00 2001 From: zm1060 Date: Mon, 16 Oct 2023 22:34:31 +0800 Subject: [PATCH 3/3] Fix error: 'WC_ERR_INVALID_CHARS' was not declared in this scope --- src/sysinfo.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sysinfo.cc b/src/sysinfo.cc index bf7017c416..ae6dba90d7 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -15,6 +15,10 @@ #include "internal_macros.h" #ifdef BENCHMARK_OS_WINDOWS +#if !defined(WINVER) || WINVER < 0x0600 +#undef WINVER +#define WINVER 0x0600 +#endif // WINVER handling #include #undef StrCat // Don't let StrCat in string_util.h be renamed to lstrcatA #include @@ -428,9 +432,6 @@ 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, WC_ERR_INVALID_CHARS, hostname, DWCOUNT, NULL, 0, NULL, NULL);