Provide fallback ___mb_cur_max_func() implementation via __p___mb_cur_max() function. __p___mb_cur_max() is available since VC20. For earlier version import libraries provide fallback __p___mb_cur_max() implementation via global variable __mb_cur_max.
With this change every CRT import library provides ___mb_cur_max_func() function. So remove #ifdefs for __mb_cur_max declarations in header files. --- mingw-w64-crt/Makefile.am | 2 ++ mingw-w64-crt/misc/___mb_cur_max_func.c | 4 ++-- mingw-w64-crt/misc/__p___mb_cur_max.c | 16 ++++++++++++++++ mingw-w64-headers/crt/ctype.h | 8 -------- mingw-w64-headers/crt/stdlib.h | 8 -------- 5 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 mingw-w64-crt/misc/__p___mb_cur_max.c diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 04224389d6a0..8442f8b94f7c 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -580,6 +580,7 @@ src_crtdll=\ misc/___mb_cur_max_func.c \ misc/__initenv.c \ misc/__p___argv.c \ + misc/__p___mb_cur_max.c \ misc/__p__acmdln.c \ misc/__p__commode.c \ misc/__p__fmode.c \ @@ -605,6 +606,7 @@ src_msvcrt10=\ misc/___mb_cur_max_func.c \ misc/__initenv.c \ misc/__p___argv.c \ + misc/__p___mb_cur_max.c \ misc/__p__acmdln.c \ misc/__p__commode.c \ misc/__p__fmode.c \ diff --git a/mingw-w64-crt/misc/___mb_cur_max_func.c b/mingw-w64-crt/misc/___mb_cur_max_func.c index 61dcdb7a6620..e37c843d88c8 100644 --- a/mingw-w64-crt/misc/___mb_cur_max_func.c +++ b/mingw-w64-crt/misc/___mb_cur_max_func.c @@ -6,12 +6,12 @@ #include <_mingw.h> -extern int* __MINGW_IMP_SYMBOL(__mb_cur_max); +_CRTIMP int* __cdecl __p___mb_cur_max(void); int __cdecl ___mb_cur_max_func(void); int __cdecl ___mb_cur_max_func(void) { - return *__MINGW_IMP_SYMBOL(__mb_cur_max); + return *__p___mb_cur_max(); } typedef int __cdecl (*_f___mb_cur_max_func)(void); diff --git a/mingw-w64-crt/misc/__p___mb_cur_max.c b/mingw-w64-crt/misc/__p___mb_cur_max.c new file mode 100644 index 000000000000..3daa1355ca67 --- /dev/null +++ b/mingw-w64-crt/misc/__p___mb_cur_max.c @@ -0,0 +1,16 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#include <_mingw.h> + +extern int* __MINGW_IMP_SYMBOL(__mb_cur_max); + +int* __cdecl __p___mb_cur_max(void); +int* __cdecl __p___mb_cur_max(void) +{ + return __MINGW_IMP_SYMBOL(__mb_cur_max); +} +int* (__cdecl *__MINGW_IMP_SYMBOL(__p___mb_cur_max))(void) = __p___mb_cur_max; diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h index bcac1c246eca..5d5e7802e9ba 100644 --- a/mingw-w64-headers/crt/ctype.h +++ b/mingw-w64-headers/crt/ctype.h @@ -201,16 +201,8 @@ int __cdecl iswblank(wint_t _C); #ifndef MB_CUR_MAX #define MB_CUR_MAX ___mb_cur_max_func() #ifndef __mb_cur_max -#ifdef _MSVCRT_ - extern int __mb_cur_max; -#define __mb_cur_max __mb_cur_max -#else -#ifndef _UCRT - extern int * __MINGW_IMP_SYMBOL(__mb_cur_max); -#endif #define __mb_cur_max (___mb_cur_max_func()) #endif -#endif _CRTIMP int __cdecl ___mb_cur_max_func(void); #endif diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h index 8e2649491cbb..b4e5e0ac7614 100644 --- a/mingw-w64-headers/crt/stdlib.h +++ b/mingw-w64-headers/crt/stdlib.h @@ -108,16 +108,8 @@ extern "C" { #ifndef MB_CUR_MAX #define MB_CUR_MAX ___mb_cur_max_func() #ifndef __mb_cur_max -#ifdef _MSVCRT_ - extern int __mb_cur_max; -#define __mb_cur_max __mb_cur_max -#else -#ifndef _UCRT - extern int * __MINGW_IMP_SYMBOL(__mb_cur_max); -#endif #define __mb_cur_max (___mb_cur_max_func()) #endif -#endif _CRTIMP int __cdecl ___mb_cur_max_func(void); #endif -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public