Skip to content

Commit 7bb9f6b

Browse files
committed
[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.
1 parent 2cc6699 commit 7bb9f6b

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

sdk/lib/ucrt/internal/winapi_thunks.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,18 +438,36 @@ extern "C" int WINAPI __acrt_CompareStringEx(
438438
return CompareStringW(__acrt_LocaleNameToLCID(locale_name, 0), flags, string1, string1_count, string2, string2_count);
439439
}
440440

441+
#ifdef __clang__
442+
static LOCALE_ENUMPROCEX static_enum_proc;
443+
static BOOL CALLBACK LocaleEnumProcW(LPWSTR locale_string)
444+
{
445+
return __crt_fast_decode_pointer(static_enum_proc)(locale_string, 0, 0);
446+
}
447+
#endif
448+
441449
// This has been split into its own function to work around a bug in the Dev12
442450
// C++ compiler where nested captureless lambdas are not convertible to the
443451
// required function pointer type.
444452
static BOOL enum_system_locales_ex_nolock(
445453
LOCALE_ENUMPROCEX const enum_proc
446454
) throw()
447455
{
456+
#ifndef __clang__
448457
static LOCALE_ENUMPROCEX static_enum_proc;
458+
#endif
449459

450460
static_enum_proc = __crt_fast_encode_pointer(enum_proc);
451-
BOOL const result = EnumSystemLocalesW(
452-
[](LPWSTR locale_string) { return __crt_fast_decode_pointer(static_enum_proc)(locale_string, 0, 0); },
461+
BOOL const result = EnumSystemLocalesW((LOCALE_ENUMPROCW)
462+
#ifdef __clang__
463+
LocaleEnumProcW,
464+
#else
465+
[](LPWSTR locale_string)
466+
#if defined(__GNUC__) && !defined(__clang__)
467+
__stdcall
468+
#endif // __GNUC__
469+
{ return __crt_fast_decode_pointer(static_enum_proc)(locale_string, 0, 0); },
470+
#endif
453471
LCID_INSTALLED);
454472
static_enum_proc = __crt_fast_encode_pointer(nullptr);
455473

0 commit comments

Comments
 (0)