From 7b9d3e90ce32e2e19f0b4725868f9a6f76346ae6 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 22 Jan 2026 19:36:54 +0200 Subject: [PATCH] Fix MS-Windows build broken by recent updates in MinGW64 headers * nt/inc/ms-w32.h (strerror): Redirect to sys_strerror after including , to prevent the linker from thinking it should be imported from some DLL. Reported by Richard Copley . * src/w32.c: Remove now unneeded prototype of sys_strerror. --- nt/inc/ms-w32.h | 8 +++++++- src/w32.c | 4 ---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h index fc853959b49..1e2af4a424e 100644 --- a/nt/inc/ms-w32.h +++ b/nt/inc/ms-w32.h @@ -227,7 +227,6 @@ extern void w32_reset_stack_overflow_guard (void); #define select sys_select #define pselect sys_select #define sleep sys_sleep -#define strerror sys_strerror #undef unlink #define unlink sys_unlink #undef opendir @@ -268,6 +267,13 @@ extern int sys_umask (int); #define cmputc sys_cmputc #define Wcm_clear sys_Wcm_clear +/* MinGW64 system headers include string.h too early, causing the + compiler to emit a warning about sys_strerror having no + prototype, or the linker fail to link. */ +#include +#define strerror sys_strerror +char *sys_strerror (int); + #endif /* emacs */ /* Used both in Emacs, in lib-src, and in Gnulib. */ diff --git a/src/w32.c b/src/w32.c index 7edc31d0a8a..c2262b441cd 100644 --- a/src/w32.c +++ b/src/w32.c @@ -84,10 +84,6 @@ int sys_dup2 (int, int); int sys_read (int, char *, unsigned int); int sys_write (int, const void *, unsigned int); struct tm *sys_localtime (const time_t *); -/* MinGW64 system headers include string.h too early, causing the - compiler to emit a warning about sys_strerror having no - prototype. */ -char *sys_strerror (int); clock_t sys_clock (void); #ifdef HAVE_MODULES