Eli Zaretskii wrote in
<https://lists.gnu.org/archive/html/bug-texinfo/2026-01/msg00099.html>,
about building GNU texinfo with mingw.org's old dead mingw:

> > Another Gnulib-related problem was with stdio-consolesafe.c:
> > 
> >      gcc -DHAVE_CONFIG_H -I. -I../..   -Id:/usr/include  -Wno-cast-qual 
> > -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef 
> > -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion 
> > -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits 
> > -Wno-unused-const-variable -Wno-unsuffixed-float-constants -Wno-error -O2 
> > -gdwarf-4 -g3 -MT libgnu_a-stdio-consolesafe.o -MD -MP -MF 
> > .deps/libgnu_a-stdio-consolesafe.Tpo -c -o libgnu_a-stdio-consolesafe.o 
> > `test -f 'stdio-consolesafe.c' || echo './'`stdio-consolesafe.c
> >      stdio-consolesafe.c:88:1: error: static declaration of 'vasprintf' 
> > follows non-static declaration
> >     88 | vasprintf (char **resultp, const char *format, va_list args)
> >        | ^~~~~~~~~
> >      In file included from stdio-consolesafe.c:20:
> >      ./stdio.h:2346:1: note: previous declaration of 'vasprintf' was here
> >       2346 | _GL_FUNCDECL_SYS (vasprintf, int,
> >        | ^~~~~~~~~~~~~~~~
> > 
> > I originally just removed the 'static' qualifier from the version of
> > vasprintf included in stdio-consolesafe.c, but that failed the link
> > step further down the line, because Gnulib also includes vasprintf.c,
> > which the MinGW build compiles and links against.  So, again as a
> > temporary kludge, I renamed the vasprintf in stdio-consolesafe.c to
> > rpl_vasprintf, and that solved the compilation and link problems.

I see: The line
  # if !HAVE_VASPRINTF
was meant to avoid a collision between this vasprintf and the global vasprintf
from mingw. But here, the global vasprintf comes from gnulib, not from mingw.

I'm applying this patch, that should fix it.


2026-01-24  Bruno Haible  <[email protected]>

        stdio-windows: Fix compilation error on old mingw.
        Reported by Eli Zaretskii in
        <https://lists.gnu.org/archive/html/bug-texinfo/2026-01/msg00099.html>.
        * lib/stdio-consolesafe.c (local_vasprintf): Renamed from vasprintf.
        (vasprintf): Define as a macro, not as a function.

diff --git a/lib/stdio-consolesafe.c b/lib/stdio-consolesafe.c
index c9486f1a32..f634de13ef 100644
--- a/lib/stdio-consolesafe.c
+++ b/lib/stdio-consolesafe.c
@@ -85,7 +85,7 @@ gl_consolesafe_fwrite (const void *ptr, size_t size, size_t 
nmemb, FILE *fp)
    specifiers as the mingw *printf functions.  */
 
 static int
-vasprintf (char **resultp, const char *format, va_list args)
+local_vasprintf (char **resultp, const char *format, va_list args)
 {
   /* First try: Use a stack-allocated buffer.  */
   char buf[2048];
@@ -123,6 +123,9 @@ vasprintf (char **resultp, const char *format, va_list args)
   return nbytes;
 }
 
+#  undef vasprintf
+#  define vasprintf local_vasprintf
+
 # endif
 
 /* Bypass the functions __mingw_[v][f]printf, that trigger a bug in msvcrt,




Reply via email to