Global variable _mbctype[] is not available in UCRT and msvcrt10.dll. UCRT instead provides __p__mbctype() function which returns pointer to the first _mbctype array member. msvcrt10.dll does not have any replacement.
Function __p__mbctype() is present also in all msvcrt VC versions starting from VC20 for all architectures. In OS system version of msvcrt.dll, this function is present only for i386 architecture. Therefore function __p__mbctype() is not present in: crtdll.dll, msvcrt10.dll and x64, arm32 and arm64 versions of msvcrt.dll. So for import libraries crtdll and x64, arm32 and arm64 versions of msvcrt provides fallback implementation of __p__mbctype() function via _mbctype[]. Then change mbctype.h include file to define _mbctype via function call __p__mbctype(). This change allows to use _mbctype with all CRT libraries, including UCRT, except msvcrt10 (which does not have neither _mbctype[], nor __p__mbctype()). --- mingw-w64-crt/Makefile.am | 4 ++++ mingw-w64-crt/misc/__p__mbctype.c | 16 ++++++++++++++++ mingw-w64-headers/crt/mbctype.h | 9 +++------ 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 mingw-w64-crt/misc/__p__mbctype.c diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 16cc3d3a5889..0fc43f8e9ad4 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -458,6 +458,7 @@ src_msvcrt64=\ misc/__p__acmdln.c \ misc/__p__commode.c \ misc/__p__fmode.c \ + misc/__p__mbctype.c \ misc/__p__wcmdln.c \ misc/_create_locale.c \ misc/_free_locale.c \ @@ -471,6 +472,7 @@ src_msvcrtarm32=\ misc/__p__acmdln.c \ misc/__p__commode.c \ misc/__p__fmode.c \ + misc/__p__mbctype.c \ misc/__p__wcmdln.c \ misc/_getpid.c \ misc/initenv.c \ @@ -569,6 +571,7 @@ src_msvcrtarm64=\ misc/__p__acmdln.c \ misc/__p__commode.c \ misc/__p__fmode.c \ + misc/__p__mbctype.c \ misc/__p__wcmdln.c \ misc/_getpid.c \ misc/initenv.c \ @@ -586,6 +589,7 @@ src_crtdll=\ misc/__p__acmdln.c \ misc/__p__commode.c \ misc/__p__fmode.c \ + misc/__p__mbctype.c \ misc/__p__pctype.c \ misc/__p__pwctype.c \ misc/__pctype_func.c \ diff --git a/mingw-w64-crt/misc/__p__mbctype.c b/mingw-w64-crt/misc/__p__mbctype.c new file mode 100644 index 000000000000..017b20a55f36 --- /dev/null +++ b/mingw-w64-crt/misc/__p__mbctype.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 unsigned char** __MINGW_IMP_SYMBOL(_mbctype); + +unsigned char* __cdecl __p__mbctype(void); +unsigned char* __cdecl __p__mbctype(void) +{ + return *__MINGW_IMP_SYMBOL(_mbctype); +} +unsigned char* (__cdecl *__MINGW_IMP_SYMBOL(__p__mbctype))(void) = __p__mbctype; diff --git a/mingw-w64-headers/crt/mbctype.h b/mingw-w64-headers/crt/mbctype.h index a43dbbf71d22..bc14b82529ea 100644 --- a/mingw-w64-headers/crt/mbctype.h +++ b/mingw-w64-headers/crt/mbctype.h @@ -14,13 +14,10 @@ extern "C" { #endif #ifndef _mbctype -#ifdef _MSVCRT_ - extern unsigned char _mbctype[257]; -#else - extern unsigned char ** __MINGW_IMP_SYMBOL(_mbctype); -#define _mbctype (* __MINGW_IMP_SYMBOL(_mbctype)) -#endif + _CRTIMP unsigned char * __cdecl __p__mbctype(void); +#define _mbctype (__p__mbctype()) #endif + #ifndef _mbcasemap #ifdef _MSVCRT_ extern unsigned char *_mbcasemap; -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public