Building a current coreutils with a current gnulib on CentOS 5 (a glibc 2.5
system), I see these compilation warning:

../lib/vasnprintf.c:3400: warning: implicit declaration of function 'mbszero'
../src/df.c:323: warning: implicit declaration of function 'mbszero'
../src/ls.c:4586: warning: implicit declaration of function 'mbszero'
../src/pathchk.c:191: warning: implicit declaration of function 'mbszero'
../src/printf.c:167: warning: implicit declaration of function 'mbszero'
../src/wc.c:409: warning: implicit declaration of function 'mbszero'

mbszero() is declared in gnulib's wchar.h override. But this override is
ineffective, as can be seen by searching for lib/wchar.h in the preprocessor
output from vasnprintf.c:

# 1 "./lib/wchar.h" 1 3 4
# 30 "./lib/wchar.h" 3 4
# 31 "./lib/wchar.h" 3
# 56 "./lib/wchar.h" 3
# 57 "./lib/wchar.h" 2 3
# 1 "./lib/wchar.h" 1 3 4
# 30 "./lib/wchar.h" 3 4
# 31 "./lib/wchar.h" 3
# 56 "./lib/wchar.h" 3
# 57 "./lib/wchar.h" 2 3
# 1 "./lib/wchar.h" 1
# 30 "./lib/wchar.h"
# 31 "./lib/wchar.h" 3
# 56 "./lib/wchar.h" 3
# 57 "./lib/wchar.h" 2 3
# 1 "./lib/wchar.h" 1
# 30 "./lib/wchar.h"
# 31 "./lib/wchar.h" 3

The reason for this is that glibc's /usr/include/wchar.h defines __need_wint_t
but never undefines it. This patch fixes the warnings:


2025-01-16  Bruno Haible  <br...@clisp.org>

        wchar_h: Fix for glibc 2.5.
        * lib/wchar.in.h (__need_wint_t): Clean up after including glibc's
        <wchar.h>.

diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index 41507f6cc5..c20040b22c 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -53,6 +53,9 @@
      <wctype.h> is completely included or is still being included.  */
 
 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
+/* The glibc 2.5 /usr/include/wchar.h defines __need_wint_t but never undefines
+   it.  We need to do that here.  */
+#undef __need_wint_t
 
 #else
 /* Normal invocation convention.  */




Reply via email to