On a recent mingw, the new wctob() test fails to compile:

../../gltests/test-wctob.c:24:18: error: initialization of 'int 
(*)(rpl_wint_t)' {aka 'int (*)(unsigned int)'} from incompatible pointer type 
'int (__attribute__((cdecl)) *)(wint_t)' {aka 'int (__attribute__((cdecl)) 
*)(short unsigned int)'} [-Wincompatible-pointer-types]
   24 | SIGNATURE_CHECK (wctob, int, (wint_t));
      |                  ^~~~~

This patch adds a workaround: It enables a wctob override.


2026-09-20  Bruno Haible  <[email protected]>

        wctob: Fix parameter type on mingw.
        * m4/wctob.m4 (gl_FUNC_WCTOB): If the gnulib headers override wint_t,
        set REPLACE_WCTOB.
        * modules/wctob (Files): Add wint_t.m4.
        * doc/posix-functions/wctob.texi: Mention the problem on newer mingw.

diff --git a/doc/posix-functions/wctob.texi b/doc/posix-functions/wctob.texi
index 284530bb3d..e524427c39 100644
--- a/doc/posix-functions/wctob.texi
+++ b/doc/posix-functions/wctob.texi
@@ -13,6 +13,9 @@
 This function is missing on some platforms:
 Minix 3.1.8, HP-UX 11.00, mingw.
 @item
+This function takes only a 16-bit integer argument on some platforms:
+mingw 14.
+@item
 This function clobbers caller-owned registers on some platforms:
 Cygwin 1.7.5.
 @item
diff --git -w a/m4/wctob.m4 b/m4/wctob.m4
index 127fd18dc5..811657af8b 100644
--- a/m4/wctob.m4
+++ b/m4/wctob.m4
@@ -1,5 +1,5 @@
 # wctob.m4
-# serial 17
+# serial 18
 dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -15,7 +15,12 @@ AC_DEFUN([gl_FUNC_WCTOB]
     HAVE_WCTOB=0
   else
     HAVE_WCTOB=1
-
+    dnl When we override wint_t, we also need to override the wctob function,
+    dnl since it takes a wint_t as parameter.
+    AC_REQUIRE([gt_TYPE_WINT_T])
+    if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then
+      REPLACE_WCTOB=1
+    else
       dnl Solaris 9 has the wctob() function but it does not work.
       dnl Cygwin 1.7.2 has the wctob() function but it clobbers caller-owned
       dnl registers, see <https://cygwin.com/ml/cygwin/2010-05/msg00015.html>.
@@ -25,8 +30,8 @@ AC_DEFUN([gl_FUNC_WCTOB]
       AC_CACHE_CHECK([whether wctob works],
         [gl_cv_func_wctob_works],
         [
-        dnl Initial guess, used when cross-compiling or when no suitable locale
-        dnl is present.
+          dnl Initial guess, used when cross-compiling or when no suitable
+          dnl locale is present.
 changequote(,)dnl
           case "$host_os" in
               # Guess no on Solaris <= 9 and Cygwin.
@@ -91,15 +96,15 @@ AC_DEFUN([gl_FUNC_WCTOB]
         *yes) ;;
         *) REPLACE_WCTOB=1 ;;
       esac
-    dnl When we adjust mbrtowc in the C locale, we need to adjust wctob as 
well,
-    dnl for consistency.
+      dnl When we adjust mbrtowc in the C locale, we need to adjust wctob
+      dnl as well, for consistency.
       AC_REQUIRE([gl_MBRTOWC_C_LOCALE])
       case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in
         *yes) ;;
-      *) REPLACE_WCTOB=1
-         ;;
+        *) REPLACE_WCTOB=1 ;;
       esac
     fi
+  fi
 ])
 
 # Prerequisites of lib/wctob.c.
diff --git a/modules/wctob b/modules/wctob
index cfd3b898d1..96d562986f 100644
--- a/modules/wctob
+++ b/modules/wctob
@@ -4,6 +4,7 @@ wctob() function: convert wide character to unibyte character.
 Files:
 lib/wctob.c
 m4/wctob.m4
+m4/wint_t.m4
 m4/mbrtowc.m4
 m4/locale-en.m4
 m4/locale-fr.m4




Reply via email to