[UCRT] Fix GCC/Clang build of enum_system_locales_ex_nolock

Add static function for Clang.
Add missing __stdcall in a lambda for GCC.
MSVC does this automagically. See https://devblogs.microsoft.com/oldnewthing/20150220-00/?p=44623.
This commit is contained in:
Timo Kreuzer 2024-10-16 13:02:08 +03:00
parent 2cc6699f0d
commit 7bb9f6bf28

View file

@ -438,6 +438,14 @@ extern "C" int WINAPI __acrt_CompareStringEx(
return CompareStringW(__acrt_LocaleNameToLCID(locale_name, 0), flags, string1, string1_count, string2, string2_count); return CompareStringW(__acrt_LocaleNameToLCID(locale_name, 0), flags, string1, string1_count, string2, string2_count);
} }
#ifdef __clang__
static LOCALE_ENUMPROCEX static_enum_proc;
static BOOL CALLBACK LocaleEnumProcW(LPWSTR locale_string)
{
return __crt_fast_decode_pointer(static_enum_proc)(locale_string, 0, 0);
}
#endif
// This has been split into its own function to work around a bug in the Dev12 // This has been split into its own function to work around a bug in the Dev12
// C++ compiler where nested captureless lambdas are not convertible to the // C++ compiler where nested captureless lambdas are not convertible to the
// required function pointer type. // required function pointer type.
@ -445,11 +453,21 @@ static BOOL enum_system_locales_ex_nolock(
LOCALE_ENUMPROCEX const enum_proc LOCALE_ENUMPROCEX const enum_proc
) throw() ) throw()
{ {
#ifndef __clang__
static LOCALE_ENUMPROCEX static_enum_proc; static LOCALE_ENUMPROCEX static_enum_proc;
#endif
static_enum_proc = __crt_fast_encode_pointer(enum_proc); static_enum_proc = __crt_fast_encode_pointer(enum_proc);
BOOL const result = EnumSystemLocalesW( BOOL const result = EnumSystemLocalesW((LOCALE_ENUMPROCW)
[](LPWSTR locale_string) { return __crt_fast_decode_pointer(static_enum_proc)(locale_string, 0, 0); }, #ifdef __clang__
LocaleEnumProcW,
#else
[](LPWSTR locale_string)
#if defined(__GNUC__) && !defined(__clang__)
__stdcall
#endif // __GNUC__
{ return __crt_fast_decode_pointer(static_enum_proc)(locale_string, 0, 0); },
#endif
LCID_INSTALLED); LCID_INSTALLED);
static_enum_proc = __crt_fast_encode_pointer(nullptr); static_enum_proc = __crt_fast_encode_pointer(nullptr);