This patch series adds missing _CRTIMP in declarations of some functions in 
several header files. There are still many places where _CRTIMP is missing, 
I'll try to take care of them later.

There are a few things I've noticed and would like to mention:

First, we have duplicating (guarded) declarations in multiple header files, 
such as various wcs* functions are declared in both wchar.h and string.h. 
Should we move them to a separate header file, similarly to what MSVC does, 
with headers like correct_wchar.h?

Second, mingw-w64 ctype.h declared four functions as external: isascii, 
toascii, iscsymf and iscsym. They all are aliases for the same functions but 
with two leading underscores (e.g. __isascii). They are declared with _CRTIMP, 
which does not seem correct to me. MSVC does not provide these four functions 
as externals, so I think it would be better to remove _CRTIMP.

Third, should we add _CRTIMP at least for some of wcs*/str* functions, such as 
{wcs,str}spn? It seems that MSVC declares at least {wcs,str}{cspn,spn,pbrk} 
with _ACRTIMP, so I think it safe to add _CRTIMP at least for those? I hesitate 
to touch the rest.

Results of GitHub CI run for this patch series are here[1].

- Kirill Makurin

[1] https://github.com/maiddaisuki/mingw-w64/actions/runs/20325886194
From 79b1e6f4bc88a39f7b9bf79cdda2cc749c0c0c10 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Thu, 18 Dec 2025 13:02:33 +0900
Subject: [PATCH 2/9] crt: add missing _CRTIMP for functions declared in
 assert.h

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/assert.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mingw-w64-headers/crt/assert.h b/mingw-w64-headers/crt/assert.h
index bce9a57cf..a8cfb2e83 100644
--- a/mingw-w64-headers/crt/assert.h
+++ b/mingw-w64-headers/crt/assert.h
@@ -22,7 +22,7 @@ extern "C" {
 #endif
 
 _CRTIMP void __cdecl __MINGW_ATTRIB_NORETURN _wassert(const wchar_t 
*_Message,const wchar_t *_File,unsigned _Line);
-void __cdecl __MINGW_ATTRIB_NORETURN _assert (const char *_Message, const char 
*_File, unsigned _Line);
+_CRTIMP void __cdecl __MINGW_ATTRIB_NORETURN _assert (const char *_Message, 
const char *_File, unsigned _Line);
 
 #ifdef __cplusplus
 }
-- 
2.51.0.windows.1

From ebb55d59a4a484ca707d0b36c0af962ffb0afe31 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Thu, 18 Dec 2025 13:03:37 +0900
Subject: [PATCH 3/9] crt: add missing _CRTIMP for functions declared in
 errno.h

Both _get_errno and _set_errno are also declared in stddef.h
and stdlib.h.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-crt/misc/_get_errno.c | 2 ++
 mingw-w64-crt/misc/_set_errno.c | 2 ++
 mingw-w64-headers/crt/errno.h   | 4 ++--
 mingw-w64-headers/crt/stddef.h  | 4 ++--
 mingw-w64-headers/crt/stdlib.h  | 4 ++--
 5 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/mingw-w64-crt/misc/_get_errno.c b/mingw-w64-crt/misc/_get_errno.c
index 64b0371c4..bf513904b 100644
--- a/mingw-w64-crt/misc/_get_errno.c
+++ b/mingw-w64-crt/misc/_get_errno.c
@@ -16,3 +16,5 @@ errno_t __cdecl _get_errno (int *_Value)
   *_Value = errno;
   return 0;
 }
+
+errno_t (__cdecl *__MINGW_IMP_SYMBOL (_get_errno)) (int *) = _get_errno;
diff --git a/mingw-w64-crt/misc/_set_errno.c b/mingw-w64-crt/misc/_set_errno.c
index 6b207c5ba..e3eff9693 100644
--- a/mingw-w64-crt/misc/_set_errno.c
+++ b/mingw-w64-crt/misc/_set_errno.c
@@ -10,3 +10,5 @@ errno_t __cdecl _set_errno (int _Value)
   errno = _Value;
   return 0;
 }
+
+errno_t (__cdecl *__MINGW_IMP_SYMBOL (_set_errno)) (int) = _set_errno;
diff --git a/mingw-w64-headers/crt/errno.h b/mingw-w64-headers/crt/errno.h
index 390f77cc5..9838a621b 100644
--- a/mingw-w64-headers/crt/errno.h
+++ b/mingw-w64-headers/crt/errno.h
@@ -17,8 +17,8 @@ extern "C" {
 _CRTIMP extern int *__cdecl _errno(void);
 #define errno (*_errno())
 
-errno_t __cdecl _set_errno(int _Value);
-errno_t __cdecl _get_errno(int *_Value);
+_CRTIMP errno_t __cdecl _set_errno(int _Value);
+_CRTIMP errno_t __cdecl _get_errno(int *_Value);
 #endif /* _CRT_ERRNO_DEFINED */
 
 #define EPERM 1
diff --git a/mingw-w64-headers/crt/stddef.h b/mingw-w64-headers/crt/stddef.h
index 03c8ebf86..614329f9c 100644
--- a/mingw-w64-headers/crt/stddef.h
+++ b/mingw-w64-headers/crt/stddef.h
@@ -17,8 +17,8 @@ extern "C" {
 #define _CRT_ERRNO_DEFINED
   _CRTIMP extern int *__cdecl _errno(void);
 #define errno (*_errno())
-  errno_t __cdecl _set_errno(int _Value);
-  errno_t __cdecl _get_errno(int *_Value);
+  _CRTIMP errno_t __cdecl _set_errno(int _Value);
+  _CRTIMP errno_t __cdecl _get_errno(int *_Value);
 #endif /* _CRT_ERRNO_DEFINED */
 
   _CRTIMP extern unsigned long __cdecl __threadid(void);
diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h
index a53c2ecb1..14b649844 100644
--- a/mingw-w64-headers/crt/stdlib.h
+++ b/mingw-w64-headers/crt/stdlib.h
@@ -145,8 +145,8 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
 #define _CRT_ERRNO_DEFINED
   _CRTIMP extern int *__cdecl _errno(void);
 #define errno (*_errno())
-  errno_t __cdecl _set_errno(int _Value);
-  errno_t __cdecl _get_errno(int *_Value);
+  _CRTIMP errno_t __cdecl _set_errno(int _Value);
+  _CRTIMP errno_t __cdecl _get_errno(int *_Value);
 #endif
   _CRTIMP unsigned long *__cdecl __doserrno(void);
 #define _doserrno (*__doserrno())
-- 
2.51.0.windows.1

From 7443cb6696d33ed57bf4d7278638ebf4ea4acf6a Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Thu, 18 Dec 2025 13:04:31 +0900
Subject: [PATCH 4/9] crt: add missing _CRTIMP for functions declared in
 locale.h

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-crt/misc/_configthreadlocale.c |  2 +-
 mingw-w64-headers/crt/locale.h           | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/mingw-w64-crt/misc/_configthreadlocale.c 
b/mingw-w64-crt/misc/_configthreadlocale.c
index cbc60139b..5196f1973 100644
--- a/mingw-w64-crt/misc/_configthreadlocale.c
+++ b/mingw-w64-crt/misc/_configthreadlocale.c
@@ -12,5 +12,5 @@ int __cdecl _configthreadlocale(int flag)
     return flag == _ENABLE_PER_THREAD_LOCALE ? -1 : _DISABLE_PER_THREAD_LOCALE;
 }
 
-void *__MINGW_IMP_SYMBOL(_configthreadlocale) = _configthreadlocale;
+int (__cdecl *__MINGW_IMP_SYMBOL(_configthreadlocale)) (int) = 
_configthreadlocale;
 
diff --git a/mingw-w64-headers/crt/locale.h b/mingw-w64-headers/crt/locale.h
index 1ec5a70ed..5d3f4cdec 100644
--- a/mingw-w64-headers/crt/locale.h
+++ b/mingw-w64-headers/crt/locale.h
@@ -86,15 +86,15 @@ extern "C" {
 
 #endif
 
-  int __cdecl _configthreadlocale(int _Flag);
-  char *__cdecl setlocale(int _Category,const char *_Locale);
+  _CRTIMP int __cdecl _configthreadlocale(int _Flag);
+  _CRTIMP char *__cdecl setlocale(int _Category,const char *_Locale);
   _CRTIMP struct lconv *__cdecl localeconv(void);
   _CRTIMP _locale_t __cdecl _get_current_locale(void);
   _CRTIMP _locale_t __cdecl _create_locale(int _Category,const char *_Locale);
   _CRTIMP void __cdecl _free_locale(_locale_t _Locale);
-  _locale_t __cdecl __get_current_locale(void);
-  _locale_t __cdecl __create_locale(int _Category,const char *_Locale);
-  void __cdecl __free_locale(_locale_t _Locale);
+  _CRTIMP _locale_t __cdecl __get_current_locale(void);
+  _CRTIMP _locale_t __cdecl __create_locale(int _Category,const char *_Locale);
+  _CRTIMP void __cdecl __free_locale(_locale_t _Locale);
 
   _CRTIMP unsigned int __cdecl ___lc_codepage_func(void);
 
-- 
2.51.0.windows.1

From 575e3967b74472af3aa65ab9dd5b6a94dbe40350 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Thu, 18 Dec 2025 13:05:25 +0900
Subject: [PATCH 5/9] crt: add missing _CRTIMP for functions declared in
 stdlib.h

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/stdlib.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h
index 14b649844..ad3192b21 100644
--- a/mingw-w64-headers/crt/stdlib.h
+++ b/mingw-w64-headers/crt/stdlib.h
@@ -342,7 +342,7 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
   __MINGW_EXTENSION _CRTIMP unsigned __int64 __cdecl _strtoui64_l(const char 
*_String,char **_EndPtr,int _Radix,_locale_t _Locale);
   ldiv_t __cdecl ldiv(long _Numerator,long _Denominator);
   _CRTIMP char *__cdecl _ltoa(long _Value,char *_Dest,int _Radix) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  int __cdecl mblen(const char *_Ch,size_t _MaxCount);
+  _CRTIMP int __cdecl mblen(const char *_Ch,size_t _MaxCount);
   _CRTIMP int __cdecl _mblen_l(const char *_Ch,size_t _MaxCount,_locale_t 
_Locale);
   _CRTIMP size_t __cdecl _mbstrlen(const char *_Str);
   _CRTIMP size_t __cdecl _mbstrlen_l(const char *_Str,_locale_t _Locale);
@@ -350,9 +350,9 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
   _CRTIMP size_t __cdecl _mbstrnlen(const char *_Str,size_t _MaxCount);
   _CRTIMP size_t __cdecl _mbstrnlen_l(const char *_Str,size_t 
_MaxCount,_locale_t _Locale);
 #endif
-  int __cdecl mbtowc(wchar_t * __restrict__ _DstCh,const char * __restrict__ 
_SrcCh,size_t _SrcSizeInBytes);
+  _CRTIMP int __cdecl mbtowc(wchar_t * __restrict__ _DstCh,const char * 
__restrict__ _SrcCh,size_t _SrcSizeInBytes);
   _CRTIMP int __cdecl _mbtowc_l(wchar_t * __restrict__ _DstCh,const char * 
__restrict__ _SrcCh,size_t _SrcSizeInBytes,_locale_t _Locale);
-  size_t __cdecl mbstowcs(wchar_t * __restrict__ _Dest,const char * 
__restrict__ _Source,size_t _MaxCount);
+  _CRTIMP size_t __cdecl mbstowcs(wchar_t * __restrict__ _Dest,const char * 
__restrict__ _Source,size_t _MaxCount);
   _CRTIMP size_t __cdecl _mbstowcs_l(wchar_t * __restrict__ _Dest,const char * 
__restrict__ _Source,size_t _MaxCount,_locale_t _Locale);
   int __cdecl mkstemp(char *template_name);
   int __cdecl rand(void);
@@ -414,9 +414,9 @@ float __cdecl __MINGW_NOTHROW strtof(const char * 
__restrict__ _Str,char ** __re
   int __cdecl system(const char *_Command);
 #endif
   _CRTIMP char *__cdecl _ultoa(unsigned long _Value,char *_Dest,int _Radix) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  int __cdecl wctomb(char *_MbCh,wchar_t _WCh) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP int __cdecl wctomb(char *_MbCh,wchar_t _WCh) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP int __cdecl _wctomb_l(char *_MbCh,wchar_t _WCh,_locale_t _Locale) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  size_t __cdecl wcstombs(char * __restrict__ _Dest,const wchar_t * 
__restrict__ _Source,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP size_t __cdecl wcstombs(char * __restrict__ _Dest,const wchar_t * 
__restrict__ _Source,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP size_t __cdecl _wcstombs_l(char * __restrict__ _Dest,const wchar_t * 
__restrict__ _Source,size_t _MaxCount,_locale_t _Locale) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 
 #ifndef _CRT_ALLOCATION_DEFINED
-- 
2.51.0.windows.1

From 2bae079a2318e4706ed84893d52498b868ac1e1a Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Thu, 18 Dec 2025 13:07:51 +0900
Subject: [PATCH 6/9] crt: add missing _CRTIMP for functions declared in
 string.h

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/string.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mingw-w64-headers/crt/string.h b/mingw-w64-headers/crt/string.h
index e947930ff..3cc584d63 100644
--- a/mingw-w64-headers/crt/string.h
+++ b/mingw-w64-headers/crt/string.h
@@ -76,7 +76,7 @@ extern "C" {
   _CRTIMP int __cdecl _stricmp(const char *_Str1,const char *_Str2);
   _CRTIMP int __cdecl _strcmpi(const char *_Str1,const char *_Str2);
   _CRTIMP int __cdecl _stricmp_l(const char *_Str1,const char *_Str2,_locale_t 
_Locale);
-  int __cdecl strcoll(const char *_Str1,const char *_Str2);
+  _CRTIMP int __cdecl strcoll(const char *_Str1,const char *_Str2);
   _CRTIMP int __cdecl _strcoll_l(const char *_Str1,const char *_Str2,_locale_t 
_Locale);
   _CRTIMP int __cdecl _stricoll(const char *_Str1,const char *_Str2);
   _CRTIMP int __cdecl _stricoll_l(const char *_Str1,const char 
*_Str2,_locale_t _Locale);
@@ -86,7 +86,7 @@ extern "C" {
   _CRTIMP int __cdecl _strnicoll_l(const char *_Str1,const char *_Str2,size_t 
_MaxCount,_locale_t _Locale);
   size_t __cdecl strcspn(const char *_Str,const char *_Control);
   _CRTIMP char *__cdecl _strerror(const char *_ErrMsg) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  char *__cdecl strerror(int) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP char *__cdecl strerror(int) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP char *__cdecl _strlwr(char *_String) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   char *strlwr_l(char *_String,_locale_t _Locale) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   char *__cdecl strncat(char * __restrict__ _Dest,const char * __restrict__ 
_Source,size_t _Count) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
@@ -101,14 +101,14 @@ extern "C" {
   _CRTIMP char *__cdecl _strrev(char *_Str);
   size_t __cdecl strspn(const char *_Str,const char *_Control);
   _CONST_RETURN char *__cdecl strstr(const char *_Str,const char *_SubStr);
-  char *__cdecl strtok(char * __restrict__ _Str,const char * __restrict__ 
_Delim) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP char *__cdecl strtok(char * __restrict__ _Str,const char * 
__restrict__ _Delim) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 #pragma push_macro("strtok_r")
 #undef strtok_r
   char *strtok_r(char * __restrict__ _Str, const char * __restrict__ _Delim, 
char ** __restrict__ __last);
 #pragma pop_macro("strtok_r")
   _CRTIMP char *__cdecl _strupr(char *_String) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP char *_strupr_l(char *_String,_locale_t _Locale) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  size_t __cdecl strxfrm(char * __restrict__ _Dst,const char * __restrict__ 
_Src,size_t _MaxCount);
+  _CRTIMP size_t __cdecl strxfrm(char * __restrict__ _Dst,const char * 
__restrict__ _Src,size_t _MaxCount);
   _CRTIMP size_t __cdecl _strxfrm_l(char * __restrict__ _Dst,const char * 
__restrict__ _Src,size_t _MaxCount,_locale_t _Locale);
 
 #ifndef        NO_OLDNAMES
-- 
2.51.0.windows.1

From 637a8984bd7280359a0fee2d4987c4486143d6e9 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Thu, 18 Dec 2025 13:09:52 +0900
Subject: [PATCH 7/9] crt: add missing _CRTIMP for functions declared in
 wchar.h

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-crt/misc/btowc.c     |  2 ++
 mingw-w64-crt/misc/mbrlen.c    |  2 ++
 mingw-w64-crt/misc/mbrtowc.c   |  2 ++
 mingw-w64-crt/misc/mbsrtowcs.c |  2 ++
 mingw-w64-crt/misc/wcrtomb.c   |  2 ++
 mingw-w64-crt/misc/wcsrtombs.c |  2 ++
 mingw-w64-crt/misc/wctob.c     |  2 ++
 mingw-w64-headers/crt/string.h |  8 ++++----
 mingw-w64-headers/crt/wchar.h  | 22 +++++++++++-----------
 9 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/mingw-w64-crt/misc/btowc.c b/mingw-w64-crt/misc/btowc.c
index a707abcfa..9f9b43246 100644
--- a/mingw-w64-crt/misc/btowc.c
+++ b/mingw-w64-crt/misc/btowc.c
@@ -32,3 +32,5 @@ wint_t btowc (int c)
 
   return wc;
 }
+
+wint_t (__cdecl *__MINGW_IMP_SYMBOL (btowc)) (int) = btowc;
diff --git a/mingw-w64-crt/misc/mbrlen.c b/mingw-w64-crt/misc/mbrlen.c
index 73111cf1d..5c7d83426 100644
--- a/mingw-w64-crt/misc/mbrlen.c
+++ b/mingw-w64-crt/misc/mbrlen.c
@@ -28,3 +28,5 @@ size_t mbrlen (
 
   return __mingw_mbrtowc_cp (NULL, mbs, count, state, cp, mb_cur_max);
 }
+
+size_t (__cdecl *__MINGW_IMP_SYMBOL (mbrlen)) (const char *, size_t, mbstate_t 
*) = mbrlen;
diff --git a/mingw-w64-crt/misc/mbrtowc.c b/mingw-w64-crt/misc/mbrtowc.c
index 8e0f0c2b9..bf656e746 100644
--- a/mingw-w64-crt/misc/mbrtowc.c
+++ b/mingw-w64-crt/misc/mbrtowc.c
@@ -29,3 +29,5 @@ size_t mbrtowc (
 
   return __mingw_mbrtowc_cp (wc, mbs, count, state, cp, mb_cur_max);
 }
+
+size_t (__cdecl *__MINGW_IMP_SYMBOL (mbrtowc)) (wchar_t *, const char *, 
size_t, mbstate_t *) = mbrtowc;
diff --git a/mingw-w64-crt/misc/mbsrtowcs.c b/mingw-w64-crt/misc/mbsrtowcs.c
index 612c29b03..6eb8246d0 100644
--- a/mingw-w64-crt/misc/mbsrtowcs.c
+++ b/mingw-w64-crt/misc/mbsrtowcs.c
@@ -87,3 +87,5 @@ size_t mbsrtowcs (
 
   return wcConverted;
 }
+
+size_t (__cdecl *__MINGW_IMP_SYMBOL (mbsrtowcs)) (wchar_t *, const char **, 
size_t, mbstate_t *) = mbsrtowcs;
diff --git a/mingw-w64-crt/misc/wcrtomb.c b/mingw-w64-crt/misc/wcrtomb.c
index 10c7bbae5..726cbb871 100644
--- a/mingw-w64-crt/misc/wcrtomb.c
+++ b/mingw-w64-crt/misc/wcrtomb.c
@@ -22,3 +22,5 @@ size_t wcrtomb (
 
   return __mingw_wcrtomb_cp (mbc, wc, state, cp, mb_cur_max);
 }
+
+size_t (__cdecl *__MINGW_IMP_SYMBOL (wcrtomb)) (char *, wchar_t, mbstate_t *) 
= wcrtomb;
diff --git a/mingw-w64-crt/misc/wcsrtombs.c b/mingw-w64-crt/misc/wcsrtombs.c
index 92538d03a..1f36223a8 100644
--- a/mingw-w64-crt/misc/wcsrtombs.c
+++ b/mingw-w64-crt/misc/wcsrtombs.c
@@ -79,3 +79,5 @@ size_t wcsrtombs (
 
   return mbcConverted;
 }
+
+size_t (__cdecl *__MINGW_IMP_SYMBOL (wcsrtombs)) (char *, const wchar_t **, 
size_t, mbstate_t *) = wcsrtombs;
diff --git a/mingw-w64-crt/misc/wctob.c b/mingw-w64-crt/misc/wctob.c
index df209be03..4a3c2408c 100644
--- a/mingw-w64-crt/misc/wctob.c
+++ b/mingw-w64-crt/misc/wctob.c
@@ -35,3 +35,5 @@ int wctob (wint_t wc)
 
   return (unsigned char) mbc[0];
 }
+
+int (__cdecl *__MINGW_IMP_SYMBOL (wctob)) (wint_t) = wctob;
diff --git a/mingw-w64-headers/crt/string.h b/mingw-w64-headers/crt/string.h
index 3cc584d63..2f1c5cb1f 100644
--- a/mingw-w64-headers/crt/string.h
+++ b/mingw-w64-headers/crt/string.h
@@ -158,8 +158,8 @@ extern "C" {
   _CONST_RETURN wchar_t *__cdecl wcsrchr(const wchar_t *_Str,wchar_t _Ch);
   size_t __cdecl wcsspn(const wchar_t *_Str,const wchar_t *_Control);
   _CONST_RETURN wchar_t *__cdecl wcsstr(const wchar_t *_Str,const wchar_t 
*_SubStr);
-  wchar_t *__cdecl wcstok(wchar_t * __restrict__ _Str,const wchar_t * 
__restrict__ _Delim,wchar_t ** __restrict__ _Ptr) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  wchar_t *__cdecl _wcstok(wchar_t * __restrict__ _Str,const wchar_t * 
__restrict__ _Delim) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP wchar_t *__cdecl wcstok(wchar_t * __restrict__ _Str,const wchar_t * 
__restrict__ _Delim,wchar_t ** __restrict__ _Ptr) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP wchar_t *__cdecl _wcstok(wchar_t * __restrict__ _Str,const wchar_t * 
__restrict__ _Delim) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 #if defined(_CRT_NON_CONFORMING_WCSTOK) && !defined(__cplusplus)
   #define wcstok _wcstok
 #endif
@@ -179,9 +179,9 @@ extern "C" {
   _CRTIMP wchar_t *_wcslwr_l(wchar_t *_String,_locale_t _Locale) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP wchar_t *__cdecl _wcsupr(wchar_t *_String) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP wchar_t *_wcsupr_l(wchar_t *_String,_locale_t _Locale) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  size_t __cdecl wcsxfrm(wchar_t * __restrict__ _Dst,const wchar_t * 
__restrict__ _Src,size_t _MaxCount);
+  _CRTIMP size_t __cdecl wcsxfrm(wchar_t * __restrict__ _Dst,const wchar_t * 
__restrict__ _Src,size_t _MaxCount);
   _CRTIMP size_t __cdecl _wcsxfrm_l(wchar_t * __restrict__ _Dst,const wchar_t 
* __restrict__ _Src,size_t _MaxCount,_locale_t _Locale);
-  int __cdecl wcscoll(const wchar_t *_Str1,const wchar_t *_Str2);
+  _CRTIMP int __cdecl wcscoll(const wchar_t *_Str1,const wchar_t *_Str2);
   _CRTIMP int __cdecl _wcscoll_l(const wchar_t *_Str1,const wchar_t 
*_Str2,_locale_t _Locale);
   _CRTIMP int __cdecl _wcsicoll(const wchar_t *_Str1,const wchar_t *_Str2);
   _CRTIMP int __cdecl _wcsicoll_l(const wchar_t *_Str1,const wchar_t 
*_Str2,_locale_t _Locale);
diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h
index 16f274353..6c489e8ff 100644
--- a/mingw-w64-headers/crt/wchar.h
+++ b/mingw-w64-headers/crt/wchar.h
@@ -1089,8 +1089,8 @@ __MINGW_ASM_CALL(__mingw_vsnwprintf);
   _CONST_RETURN wchar_t *__cdecl wcsrchr(const wchar_t *_Str,wchar_t _Ch);
   size_t __cdecl wcsspn(const wchar_t *_Str,const wchar_t *_Control);
   _CONST_RETURN wchar_t *__cdecl wcsstr(const wchar_t *_Str,const wchar_t 
*_SubStr);
-  wchar_t *__cdecl wcstok(wchar_t * __restrict__ _Str,const wchar_t * 
__restrict__ _Delim,wchar_t ** __restrict__ _Ptr) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  wchar_t *__cdecl _wcstok(wchar_t * __restrict__ _Str,const wchar_t * 
__restrict__ _Delim) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP wchar_t *__cdecl wcstok(wchar_t * __restrict__ _Str,const wchar_t * 
__restrict__ _Delim,wchar_t ** __restrict__ _Ptr) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP wchar_t *__cdecl _wcstok(wchar_t * __restrict__ _Str,const wchar_t * 
__restrict__ _Delim) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 #if defined(_CRT_NON_CONFORMING_WCSTOK) && !defined(__cplusplus)
   #define wcstok _wcstok
 #endif
@@ -1110,9 +1110,9 @@ __MINGW_ASM_CALL(__mingw_vsnwprintf);
   _CRTIMP wchar_t *_wcslwr_l(wchar_t *_String,_locale_t _Locale) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP wchar_t *__cdecl _wcsupr(wchar_t *_String) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
   _CRTIMP wchar_t *_wcsupr_l(wchar_t *_String,_locale_t _Locale) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  size_t __cdecl wcsxfrm(wchar_t * __restrict__ _Dst,const wchar_t * 
__restrict__ _Src,size_t _MaxCount);
+  _CRTIMP size_t __cdecl wcsxfrm(wchar_t * __restrict__ _Dst,const wchar_t * 
__restrict__ _Src,size_t _MaxCount);
   _CRTIMP size_t __cdecl _wcsxfrm_l(wchar_t * __restrict__ _Dst,const wchar_t 
* __restrict__ _Src,size_t _MaxCount,_locale_t _Locale);
-  int __cdecl wcscoll(const wchar_t *_Str1,const wchar_t *_Str2);
+  _CRTIMP int __cdecl wcscoll(const wchar_t *_Str1,const wchar_t *_Str2);
   _CRTIMP int __cdecl _wcscoll_l(const wchar_t *_Str1,const wchar_t 
*_Str2,_locale_t _Locale);
   _CRTIMP int __cdecl _wcsicoll(const wchar_t *_Str1,const wchar_t *_Str2);
   _CRTIMP int __cdecl _wcsicoll_l(const wchar_t *_Str1,const wchar_t 
*_Str2,_locale_t _Locale);
@@ -1204,14 +1204,14 @@ __MINGW_ASM_CALL(__mingw_vsnwprintf);
 #endif
   typedef wchar_t _Wint_t;
 
-  wint_t __cdecl btowc(int);
+  _CRTIMP wint_t __cdecl btowc(int);
   int __cdecl mbsinit(const mbstate_t *ps);
-  size_t __cdecl mbrlen(const char * __restrict__ _Ch,size_t 
_SizeInBytes,mbstate_t * __restrict__ _State);
-  size_t __cdecl mbrtowc(wchar_t * __restrict__ _DstCh,const char * 
__restrict__ _SrcCh,size_t _SizeInBytes,mbstate_t * __restrict__ _State);
-  size_t __cdecl mbsrtowcs(wchar_t * __restrict__ _Dest,const char ** 
__restrict__ _PSrc,size_t _Count,mbstate_t * __restrict__ _State) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  size_t __cdecl wcrtomb(char * __restrict__ _Dest,wchar_t _Source,mbstate_t * 
__restrict__ _State) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  size_t __cdecl wcsrtombs(char * __restrict__ _Dest,const wchar_t ** 
__restrict__ _PSource,size_t _Count,mbstate_t * __restrict__ _State) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
-  int __cdecl wctob(wint_t _WCh);
+  _CRTIMP size_t __cdecl mbrlen(const char * __restrict__ _Ch,size_t 
_SizeInBytes,mbstate_t * __restrict__ _State);
+  _CRTIMP size_t __cdecl mbrtowc(wchar_t * __restrict__ _DstCh,const char * 
__restrict__ _SrcCh,size_t _SizeInBytes,mbstate_t * __restrict__ _State);
+  _CRTIMP size_t __cdecl mbsrtowcs(wchar_t * __restrict__ _Dest,const char ** 
__restrict__ _PSrc,size_t _Count,mbstate_t * __restrict__ _State) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP size_t __cdecl wcrtomb(char * __restrict__ _Dest,wchar_t 
_Source,mbstate_t * __restrict__ _State) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP size_t __cdecl wcsrtombs(char * __restrict__ _Dest,const wchar_t ** 
__restrict__ _PSource,size_t _Count,mbstate_t * __restrict__ _State) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  _CRTIMP int __cdecl wctob(wint_t _WCh);
 
 #ifndef __NO_ISOCEXT /* these need static lib libmingwex.a */
   wchar_t *__cdecl wmemset(wchar_t *s, wchar_t c, size_t n);
-- 
2.51.0.windows.1

From 4497cff914baff86038de1378c52c4a43c0b6b11 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Thu, 18 Dec 2025 13:10:14 +0900
Subject: [PATCH 8/9] crt: add missing _CRTIMP for functions declared in
 wctype.h

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-crt/misc/wctrans.c   | 3 +++
 mingw-w64-crt/misc/wctype.c    | 2 ++
 mingw-w64-headers/crt/wctype.h | 6 +++---
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-crt/misc/wctrans.c b/mingw-w64-crt/misc/wctrans.c
index bcd9ef9fa..a45bbf18e 100644
--- a/mingw-w64-crt/misc/wctrans.c
+++ b/mingw-w64-crt/misc/wctrans.c
@@ -63,3 +63,6 @@ wint_t towctrans (wint_t wc, wctrans_t desc)
       return wc;
    }
 }
+
+wctrans_t (__cdecl *__MINGW_IMP_SYMBOL (wctrans)) (const char *) = wctrans;
+wint_t (__cdecl *__MINGW_IMP_SYMBOL (towctrans)) (wint_t, wctrans_t) = 
towctrans;
diff --git a/mingw-w64-crt/misc/wctype.c b/mingw-w64-crt/misc/wctype.c
index b6cfc1ddf..0a325b58a 100644
--- a/mingw-w64-crt/misc/wctype.c
+++ b/mingw-w64-crt/misc/wctype.c
@@ -63,3 +63,5 @@ wctype_t wctype (const char *property)
       return cmap[i].flags;
   return 0;
 }
+
+wctype_t (__cdecl *__MINGW_IMP_SYMBOL (wctype)) (const char *) = wctype;
diff --git a/mingw-w64-headers/crt/wctype.h b/mingw-w64-headers/crt/wctype.h
index 418d75e9e..96dc2b47c 100644
--- a/mingw-w64-headers/crt/wctype.h
+++ b/mingw-w64-headers/crt/wctype.h
@@ -13,9 +13,9 @@ extern "C" {
 #endif
 
   typedef wchar_t wctrans_t;
-  wint_t __cdecl towctrans(wint_t,wctrans_t);
-  wctrans_t __cdecl wctrans(const char *);
-  wctype_t __cdecl wctype(const char *);
+  _CRTIMP wint_t __cdecl towctrans(wint_t,wctrans_t);
+  _CRTIMP wctrans_t __cdecl wctrans(const char *);
+  _CRTIMP wctype_t __cdecl wctype(const char *);
 
 #ifdef __cplusplus
 }
-- 
2.51.0.windows.1

From 21d28f97dc9c811c99a35c701b707d19ba2f0150 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Thu, 18 Dec 2025 13:10:34 +0900
Subject: [PATCH 9/9] crt: add missing _CRTIMP for functions declared in
 uchar.h

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/uchar.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mingw-w64-headers/crt/uchar.h b/mingw-w64-headers/crt/uchar.h
index 7c32e7025..07894a497 100644
--- a/mingw-w64-headers/crt/uchar.h
+++ b/mingw-w64-headers/crt/uchar.h
@@ -49,21 +49,21 @@ extern "C" {
 
 #ifdef _UCRT
 
-size_t mbrtoc16 (char16_t *__restrict__ pc16,
+_CRTIMP size_t mbrtoc16 (char16_t *__restrict__ pc16,
                 const char *__restrict__ s,
                 size_t n,
                 mbstate_t *__restrict__ ps);
 
-size_t c16rtomb (char *__restrict__ s,
+_CRTIMP size_t c16rtomb (char *__restrict__ s,
                 char16_t c16,
                 mbstate_t *__restrict__ ps);
 
-size_t mbrtoc32 (char32_t *__restrict__ pc32,
+_CRTIMP size_t mbrtoc32 (char32_t *__restrict__ pc32,
                 const char *__restrict__ s,
                 size_t n,
                 mbstate_t *__restrict__ ps);
 
-size_t c32rtomb (char *__restrict__ s,
+_CRTIMP size_t c32rtomb (char *__restrict__ s,
                 char32_t c32,
                 mbstate_t *__restrict__ ps);
 
-- 
2.51.0.windows.1

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to