From 456026b19182b610f11d5ecfe010ac02f8ca9cc8 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Fri, 21 Apr 2023 10:45:59 -0600 Subject: [PATCH] Fix mingw locale builds Experience has shown that mingw with an older runtime library doesn't have more modern Windows features working properly. This commit causes it to compile with workarounds, but allows the user to -Accflags='-DUCRT_USED' to indicate to Configure that the code will be using the modern CRT. --- perl.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/perl.h b/perl.h index 1f5e94f08605..84405da3a057 100644 --- a/perl.h +++ b/perl.h @@ -1355,7 +1355,7 @@ typedef enum { * Windows for any vintage recent enough to have _MSC_VER defined */ # if defined(USE_LOCALE_THREADS) && ! defined(NO_THREAD_SAFE_LOCALE) # if defined(USE_POSIX_2008_LOCALE) \ - || (defined(WIN32) && defined(_MSC_VER)) + || (defined(WIN32) && (defined(_MSC_VER) || defined(UCRT_USED))) # define USE_THREAD_SAFE_LOCALE # else # define EMULATE_THREAD_SAFE_LOCALES @@ -1401,13 +1401,19 @@ typedef enum { * thinks LC_ALL is so as to inform the Windows libc when switching * contexts. */ # define USE_PL_CUR_LC_ALL +# endif /* Microsoft documentation reads in the change log for VS 2015: "The * localeconv function declared in locale.h now works correctly when * per-thread locale is enabled. In previous versions of the library, this * function would return the lconv data for the global locale, not the - * thread's locale." */ -# if _MSC_VER < 1900 + * thread's locale." + * + * Mingw without UCRT is likely broken */ +# if defined(WIN32) +# if ! defined(_MSC_VER) && ! defined(UCRT_USED) +# define TS_W32_BROKEN_LOCALECONV +# elif _MSC_VER < 1900 # define TS_W32_BROKEN_LOCALECONV # endif # endif