]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix compilation errors in emacsclient.c with MinGW GCC 15
authorEli Zaretskii <eliz@gnu.org>
Wed, 30 Apr 2025 11:06:44 +0000 (14:06 +0300)
committerEshel Yaron <me@eshelyaron.com>
Thu, 1 May 2025 08:26:37 +0000 (10:26 +0200)
* lib-src/emacsclient.c (set_fg, get_wc): Declare using actual
function signatures.
(w32_give_focus): Cast return value of 'GetProcAddress' to correct
pointer types.  (Bug#78160)

(cherry picked from commit 6c2aaedfcebb310e0c948d6972f90cc7d96193f9)

lib-src/emacsclient.c

index 21e8d171574cf861255ec1c6209ae46d1762e2f9..a0b1cfff392cc533eca70bc0b4d365a96904d0bd 100644 (file)
@@ -1715,8 +1715,13 @@ set_socket (bool no_exit_if_error)
 }
 
 #ifdef HAVE_NTGUI
-FARPROC set_fg;  /* Pointer to AllowSetForegroundWindow.  */
-FARPROC get_wc;  /* Pointer to RealGetWindowClassA.  */
+typedef void (* VOIDFNPTR) (void);
+typedef BOOL (WINAPI *AllowSetForegroundWindow_proc) (DWORD);
+/* Pointer to AllowSetForegroundWindow.  */
+static AllowSetForegroundWindow_proc set_fg;
+typedef UINT (WINAPI *RealGetWindowClassA_proc) (HWND, LPSTR, UINT);
+/* Pointer to RealGetWindowClassA.  */
+static RealGetWindowClassA_proc get_wc;
 
 void w32_set_user_model_id (void);
 
@@ -1794,8 +1799,8 @@ w32_give_focus (void)
      emacsclient can allow Emacs to grab the focus by calling the function
      AllowSetForegroundWindow.  Unfortunately, older Windows (W95, W98 and
      NT) lack this function, so we have to check its availability.  */
-  if ((set_fg = GetProcAddress (user32, "AllowSetForegroundWindow"))
-      && (get_wc = GetProcAddress (user32, "RealGetWindowClassA")))
+  if ((set_fg = (AllowSetForegroundWindow_proc) (VOIDFNPTR) GetProcAddress (user32, "AllowSetForegroundWindow"))
+      && (get_wc = (RealGetWindowClassA_proc) (VOIDFNPTR) GetProcAddress (user32, "RealGetWindowClassA")))
     EnumWindows (w32_find_emacs_process, (LPARAM) 0);
 }
 #endif /* HAVE_NTGUI */