On mingw-w64 with UCRT option, I see this compilation error: gcc -std=gnu23 -DHAVE_CONFIG_H -DEXEEXT=\".exe\" -DEXEEXT=\".exe\" -I. -I../../gltests -I.. -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. -I../../gltests/.. -I../gllib -I../../gltests/../gllib -I/usr/local/ucrt64/include -Wall -Wno-error -g -O2 -c -o test-btowc.o ../../gltests/test-btowc.c In file included from ../../gltests/test-btowc.c:23: ../../gltests/test-btowc.c:24:18: error: initialization of 'rpl_wint_t (*)(int)' {aka 'unsigned int (*)(int)'} from incompatible pointer type 'wint_t (*)(int)' {aka 'short unsigned int (*)(int)'} [-Wincompatible-pointer-types] 24 | SIGNATURE_CHECK (btowc, wint_t, (int)); | ^~~~~ ../../gltests/signature.h:46:57: note: in definition of macro 'SIGNATURE_CHECK2' 46 | _GL_UNUSED static ret (*signature_check ## id) args = fn | ^~ ../../gltests/signature.h:39:3: note: in expansion of macro 'SIGNATURE_CHECK1' 39 | SIGNATURE_CHECK1 (fn, ret, args, __LINE__) | ^~~~~~~~~~~~~~~~ ../../gltests/test-btowc.c:24:1: note: in expansion of macro 'SIGNATURE_CHECK' 24 | SIGNATURE_CHECK (btowc, wint_t, (int)); | ^~~~~~~~~~~~~~~ make[4]: *** [Makefile:27542: test-btowc.o] Error 1
I recall having seen this as a warning (with older mingw or with MSVC). But gcc 14, which is in use here, is stricter and does not allow an implicit conversion from unsigned short (*)(int) to unsigned int (*)(int) (because in ISO C, argument promotion happens for the parameters, but not for the result type). This patch fixes it. 2024-12-22 Bruno Haible <br...@clisp.org> btowc: Fix declaration on mingw/ucrt. * m4/btowc.m4 (gl_FUNC_BTOWC): Require gt_TYPE_WINT_T. If gnulib overrides wint_t, set REPLACE_BTOWC to 1. diff --git a/m4/btowc.m4 b/m4/btowc.m4 index e5cab9662c..1aa12130e0 100644 --- a/m4/btowc.m4 +++ b/m4/btowc.m4 @@ -1,5 +1,5 @@ # btowc.m4 -# serial 14 +# serial 15 dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,6 +9,7 @@ AC_DEFUN([gl_FUNC_BTOWC], [ AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + AC_REQUIRE([gt_TYPE_WINT_T]) dnl Check whether <wchar.h> is usable at all, first. Otherwise the test dnl program below may lead to an endless loop. See @@ -134,6 +135,13 @@ AC_DEFUN([gl_FUNC_BTOWC] ]) ]) + if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then + dnl On mingw/ucrt, we override the return type of btowc(). + dnl While the original wint_t (= unsigned short) and the overridden wint_t + dnl (= unsigned int) are equivalent in function parameters, this is not + dnl the case for function return types. + REPLACE_BTOWC=1 + fi case "$gl_cv_func_btowc_nul" in *yes) ;; *) REPLACE_BTOWC=1 ;;