On 2025-11-06 13:42, Andy Moreton wrote:

With master commit 50a1929f6c0a ("Update from Gnulib by running
admin/merge-gnulib") I see the build fails from a clean checkout:

make[2]: Entering directory 
'/c/emacs/git/emacs/master/build/mingw64-x86_64-O2-native/lib'
   CC       stdio-consolesafe.o
C:/emacs/git/emacs/master/lib/stdio-consolesafe.c:59:1: warning: no previous 
prototype for 'gl_consolesafe_fwrite' [-Wmissing-prototypes]
    59 | gl_consolesafe_fwrite (const void *ptr, size_t size, size_t nmemb, 
FILE *fp)
       | ^~~~~~~~~~~~~~~~~~~~~
C:/emacs/git/emacs/master/lib/stdio-consolesafe.c:133:1: warning: no previous 
prototype for 'gl_consolesafe_fprintf' [-Wmissing-prototypes]
   133 | gl_consolesafe_fprintf (FILE *restrict fp, const char *restrict 
format, ...)
       | ^~~~~~~~~~~~~~~~~~~~~~

Thanks for checking this. The above two messages (and similar ones) suggest that the following lines in lib/stdio.h are not working as expected:

  #if (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT
  /* Workarounds against msvcrt bugs.  */
  _GL_FUNCDECL_SYS (gl_consolesafe_fwrite, size_t,
                    (const void *ptr, size_t size, size_t nmemb, FILE *fp),
                    _GL_ARG_NONNULL ((1, 4)));
  # if defined __MINGW32__
  _GL_FUNCDECL_SYS (gl_consolesafe_fprintf, int,
                    (FILE *restrict fp, const char *restrict format, ...),
                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
                    _GL_ARG_NONNULL ((1, 2)));

Can you figure out why that might be?  E.g., run the command

make V=1

to see what "CC stdio-consolesafe.o" is actually doing, and then use the compiler's -E flag (or better yet, -dD -E if that's supported) to see whether _WIN32, __CYGWIN__, _UCRT and __MINGW32__ have the expected values for your platform, whatever they may be.


C:/emacs/git/emacs/master/lib/stdio-consolesafe.c: In function 
'gl_consolesafe_fprintf':
C:/emacs/git/emacs/master/lib/stdio-consolesafe.c:137:3: error: implicit 
declaration of function 'va_start' [-Wimplicit-function-declaration]
   137 |   va_start (args, format);
       |   ^~~~~~~~

That (and similar messages) seem to be due to an obvious typo, which I fixed that by installing the attached into Gnulib and propagating this into Emacs.
From 5d034e407e23c0514f928ae0a8a63704a3c311e9 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Thu, 6 Nov 2025 14:32:10 -0800
Subject: [PATCH] stdio-windows: fix <stdarg.h> include position

Problem reported by Andy Moreton in:
https://lists.gnu.org/r/bug-gnulib/2025-11/msg00059.html
* lib/stdio-consolesafe.c [__MINGW32__ && __USE_MINGW_ANSI_STDIO]:
Include <stdarg.h> even if HAVE_VASPRINTF
---
 ChangeLog               | 8 ++++++++
 lib/stdio-consolesafe.c | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e40604e420..f3a5d317fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-11-06  Paul Eggert  <[email protected]>
+
+	stdio-windows: fix <stdarg.h> include position
+	Problem reported by Andy Moreton in:
+	https://lists.gnu.org/r/bug-gnulib/2025-11/msg00059.html
+	* lib/stdio-consolesafe.c [__MINGW32__ && __USE_MINGW_ANSI_STDIO]:
+	Include <stdarg.h> even if HAVE_VASPRINTF
+
 2025-11-06  Bruno Haible  <[email protected]>
 
 	posix_spawn-internal: Don't use vfork() on Solaris/SPARC.
diff --git a/lib/stdio-consolesafe.c b/lib/stdio-consolesafe.c
index b5ca8cc012..80561a6da4 100644
--- a/lib/stdio-consolesafe.c
+++ b/lib/stdio-consolesafe.c
@@ -74,11 +74,11 @@ gl_consolesafe_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *fp)
 #if defined __MINGW32__ && __USE_MINGW_ANSI_STDIO
 
 # include "fseterr.h"
+# include <stdarg.h>
 
 # if !HAVE_VASPRINTF
 
 #  include <errno.h>
-#  include <stdarg.h>
 
 /* The old mingw (before mingw-w64) does not have the vasprintf function.
    Define a suitable replacement here, that supports the same format
-- 
2.51.0

Reply via email to