Subject: Re: bug#62792: Emacs 29.0.90 build fails

From: Eli Zaretskii <[email-masked]>
Date: Wed, 12 Apr 2023 21:57:59 +0300

> From: Tak Ota <[email-masked]>
> Date: Wed, 12 Apr 2023 11:45:58 -0700
> Cc: [email-masked]
> 
> #define __MINGW32_VERSION           3022004L
> #define __MINGW32_MAJOR_VERSION           3
> #define __MINGW32_MINOR_VERSION          22
> #define __MINGW32_PATCHLEVEL              4

OK, thanks.  I think I see the reason now.  Please try the patch below
and tell if it solves the problem.

diff --git a/src/w32.c b/src/w32.c
index 8d344d2..bb3b35f 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -543,7 +543,13 @@ int (WINAPI *pWideCharToMultiByte)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOO
 
 typedef COORD (WINAPI *GetConsoleFontSize_Proc) (HANDLE, DWORD);
 
-#if _WIN32_WINNT < 0x0501
+/* Old versions of mingw.org's MinGW, before v5.2.0, don't have a
+   _WIN32_WINNT guard for CONSOLE_FONT_INFO in wincon.h, which causes
+   compilation errors.  Note: MinGW64 sets _WIN32_WINNT to a higher
+   version, and its w32api.h version stays fixed at 3.14.  */
+#if _WIN32_WINNT < 0x0501 \
+    && (__W32API_MAJOR_VERSION > 5 \
+	|| (__W32API_MAJOR_VERSION == 5 && __W32API_MINOR_VERSION >= 2))
 typedef struct
 {
   DWORD nFont;