This is a follow up for my previous patch for ctype.h. Rationale is in the 
commit messages.

First patch fixes compilation error in btowc.c. It referenced MB_CUR_MAX but 
didn't include stdlib.h. I think windows.h at some points includes ctype.h, so 
this is how btowc.c was able to compile.

- Kirill Makurin
From 2050525bba75dc0eaa217b4f6825fa52d33a5c78 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Wed, 13 May 2026 19:29:57 +0900
Subject: [PATCH 1/2] crt: btowc.c: include stdlib.h

It references MB_CUR_MAX, which is defined in stdlib.h, but does include it.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-crt/misc/btowc.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/mingw-w64-crt/misc/btowc.c b/mingw-w64-crt/misc/btowc.c
index 9f9b43246..d69b6bd03 100644
--- a/mingw-w64-crt/misc/btowc.c
+++ b/mingw-w64-crt/misc/btowc.c
@@ -6,14 +6,10 @@
 
 #define __LARGE_MBSTATE_T
 
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include <locale.h>
-#include <limits.h>
+#include <limits.h> /* MB_LEN_MAX */
 #include <wchar.h>
-#include <stdio.h>
-#include <windows.h>
+#include <stdio.h>  /* EOF        */
+#include <stdlib.h> /* MB_CUR_MAX */
 
 wint_t btowc (int c)
 {
-- 
2.51.0.windows.1

From 2bab74799c954e0a0bd5c9fd71e51acbac75ff7b Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Wed, 13 May 2026 19:32:57 +0900
Subject: [PATCH 2/2] crt: ctype.h: remove definition for MB_CUR_MAX

Microsoft header files define MB_CUR_MAX in ctype.h; it is used in
implementation of macro versions of standard C functions such as `isalpha`.

mingw-w64 header files do not provide macro versions for those functions,
so there is no reason to provide definition for MB_CUR_MAX in ctype.h.

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

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 86f7f86d7..6d5ce4211 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -12,18 +12,6 @@
 extern "C" {
 #endif
 
-#ifndef _CTYPE_DISABLE_MACROS
-
-#ifndef MB_CUR_MAX
-#define MB_CUR_MAX ___mb_cur_max_func()
-#ifndef __mb_cur_max
-#define __mb_cur_max   (___mb_cur_max_func())
-#endif
-_CRTIMP int __cdecl ___mb_cur_max_func(void);
-#endif
-
-#endif /* !_CTYPE_DISABLE_MACROS */
-
 /**
  * Standard C functions.
  */
-- 
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