GNU bug report logs -
#78160
Emacs fail to build with GCC 15
Previous Next
Reported by: MAN ONE <pRoMMMModE <at> outlook.com>
Date: Wed, 30 Apr 2025 06:57:03 UTC
Severity: normal
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 78160 in the body.
You can then email your comments to 78160 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78160
; Package
emacs
.
(Wed, 30 Apr 2025 06:57:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
MAN ONE <pRoMMMModE <at> outlook.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 30 Apr 2025 06:57:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Earlier this week Msys2 upgraded GCC to version 15.1.0, which lead to this build error:
emacsclient.c:1718:9: warning: no previous declaration for 'set_fg' [-Wmissing-variable-de
clarations]
1718 | FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */
| ^~~~~~
emacsclient.c:1719:9: warning: no previous declaration for 'get_wc' [-Wmissing-variable-de
clarations]
1719 | FARPROC get_wc; /* Pointer to RealGetWindowClassA. */
| ^~~~~~
emacsclient.c: In function 'w32_find_emacs_process':
emacsclient.c:1759:9: error: too many arguments to function 'get_wc'; expected 0, have 3
1759 | if (! get_wc (hWnd, class, sizeof (class))
| ^~~~~~ ~~~~
emacsclient.c:1770:3: error: too many arguments to function 'set_fg'; expected 0, have 1
1770 | set_fg (emacs_pid);
| ^~~~~~ ~~~~~~~~~
emacsclient.c:1718:9: warning: no previous declaration for 'set_fg' [-Wmissing-variable-de
clarations]
1718 | FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */
| ^~~~~~
emacsclient.c:1719:9: warning: no previous declaration for 'get_wc' [-Wmissing-variable-de
clarations]
1719 | FARPROC get_wc; /* Pointer to RealGetWindowClassA. */
| ^~~~~~
emacsclient.c: In function 'w32_find_emacs_process':
emacsclient.c:1759:9: error: too many arguments to function 'get_wc'; expected 0, have 3
1759 | if (! get_wc (hWnd, class, sizeof (class))
| ^~~~~~ ~~~~
emacsclient.c:1770:3: error: too many arguments to function 'set_fg'; expected 0, have 1
1770 | set_fg (emacs_pid);
| ^~~~~~ ~~~~~~~~~
make[2]: *** [Makefile:446: emacsclientw.exe] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:439: emacsclient.exe] Error 1
make[2]: Leaving directory '/e/home/repo/emacs/lib-src'
make[1]: *** [Makefile:529: lib-src] Error 2
make[1]: *** Waiting for unfinished jobs....
I think the cause is GCC 15 now use C23 by default[1], and appending ` -std=gnu17 ` compiler flag does solve the problem.
[1]https://gcc.gnu.org/gcc-15/porting_to.html#c23
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78160
; Package
emacs
.
(Wed, 30 Apr 2025 08:17:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 78160 <at> debbugs.gnu.org (full text, mbox):
> From: MAN ONE <pRoMMMModE <at> outlook.com>
> Date: Wed, 30 Apr 2025 04:38:42 +0000
> msip_labels:
>
> Earlier this week Msys2 upgraded GCC to version 15.1.0, which lead to this build error:
>
>
> emacsclient.c:1718:9: warning: no previous declaration for 'set_fg' [-Wmissing-variable-de
> clarations]
> 1718 | FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */
> | ^~~~~~
> emacsclient.c:1719:9: warning: no previous declaration for 'get_wc' [-Wmissing-variable-de
> clarations]
> 1719 | FARPROC get_wc; /* Pointer to RealGetWindowClassA. */
> | ^~~~~~
> emacsclient.c: In function 'w32_find_emacs_process':
> emacsclient.c:1759:9: error: too many arguments to function 'get_wc'; expected 0, have 3
> 1759 | if (! get_wc (hWnd, class, sizeof (class))
> | ^~~~~~ ~~~~
> emacsclient.c:1770:3: error: too many arguments to function 'set_fg'; expected 0, have 1
> 1770 | set_fg (emacs_pid);
> | ^~~~~~ ~~~~~~~~~
> emacsclient.c:1718:9: warning: no previous declaration for 'set_fg' [-Wmissing-variable-de
> clarations]
> 1718 | FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */
> | ^~~~~~
> emacsclient.c:1719:9: warning: no previous declaration for 'get_wc' [-Wmissing-variable-de
> clarations]
> 1719 | FARPROC get_wc; /* Pointer to RealGetWindowClassA. */
> | ^~~~~~
> emacsclient.c: In function 'w32_find_emacs_process':
> emacsclient.c:1759:9: error: too many arguments to function 'get_wc'; expected 0, have 3
> 1759 | if (! get_wc (hWnd, class, sizeof (class))
> | ^~~~~~ ~~~~
> emacsclient.c:1770:3: error: too many arguments to function 'set_fg'; expected 0, have 1
> 1770 | set_fg (emacs_pid);
> | ^~~~~~ ~~~~~~~~~
> make[2]: *** [Makefile:446: emacsclientw.exe] Error 1
> make[2]: *** Waiting for unfinished jobs....
> make[2]: *** [Makefile:439: emacsclient.exe] Error 1
> make[2]: Leaving directory '/e/home/repo/emacs/lib-src'
> make[1]: *** [Makefile:529: lib-src] Error 2
> make[1]: *** Waiting for unfinished jobs....
>
>
> I think the cause is GCC 15 now use C23 by default[1], and appending ` -std=gnu17 ` compiler flag does solve the problem.
Thanks for the report. Does the patch below solve these problems?
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 2cf90f4..d783af9 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1715,8 +1715,12 @@ set_socket (bool no_exit_if_error)
}
#ifdef HAVE_NTGUI
-FARPROC set_fg; /* Pointer to AllowSetForegroundWindow. */
-FARPROC get_wc; /* Pointer to RealGetWindowClassA. */
+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 +1798,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) GetProcAddress (user32, "AllowSetForegroundWindow"))
+ && (get_wc = (RealGetWindowClassA_proc) GetProcAddress (user32, "RealGetWindowClassA")))
EnumWindows (w32_find_emacs_process, (LPARAM) 0);
}
#endif /* HAVE_NTGUI */
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78160
; Package
emacs
.
(Wed, 30 Apr 2025 10:07:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 78160 <at> debbugs.gnu.org (full text, mbox):
> From: MAN ONE <pRoMMMModE <at> outlook.com>
> CC: "78160 <at> debbugs.gnu.org" <78160 <at> debbugs.gnu.org>
> Date: Wed, 30 Apr 2025 09:23:51 +0000
> msip_labels:
>
> Thanks, the patch solved the compilation error, and the compiled binary seems working fine.
> However GCC also output some warnings ( actually GCC output a LOT of warnings, I just gonna paste warnings that only relate to the patch.)
>
> make[2]: Entering directory '/e/home/repo/emacs/lib-src'
> CC ntlib.o
> CCLD etags.exe
> CCLD emacsclient.exe
> emacsclient.c: In function 'w32_give_focus':
> emacsclient.c:1801:17: warning: cast between incompatible function types from 'FARPROC' {a
> ka 'long long int (*)(void)'} to 'BOOL (*)(DWORD)' {aka 'int (*)(long unsigned int)'} [-Wc
> ast-function-type]
> 1801 | if ((set_fg = (AllowSetForegroundWindow_proc) GetProcAddress (user32, "AllowSetF
> oregroundWindow"))
> | ^
> emacsclient.c:1802:20: warning: cast between incompatible function types from 'FARPROC' {a
> ka 'long long int (*)(void)'} to 'UINT (*)(struct HWND__ *, CHAR *, UINT)' {aka 'unsigned
> int (*)(struct HWND__ *, char *, unsigned int)'} [-Wcast-function-type]
> 1802 | && (get_wc = (RealGetWindowClassA_proc) GetProcAddress (user32, "RealGetWind
> owClassA")))
> | ^
> RC emacsclient.res
> CCLD emacsclientw.exe
> emacsclient.c: In function 'w32_give_focus':
> emacsclient.c:1801:17: warning: cast between incompatible function types from 'FARPROC' {a
> ka 'long long int (*)(void)'} to 'BOOL (*)(DWORD)' {aka 'int (*)(long unsigned int)'} [-Wc
> ast-function-type]
> 1801 | if ((set_fg = (AllowSetForegroundWindow_proc) GetProcAddress (user32, "AllowSetF
> oregroundWindow"))
> | ^
> emacsclient.c:1802:20: warning: cast between incompatible function types from 'FARPROC' {a
> ka 'long long int (*)(void)'} to 'UINT (*)(struct HWND__ *, CHAR *, UINT)' {aka 'unsigned
> int (*)(struct HWND__ *, char *, unsigned int)'} [-Wcast-function-type]
> 1802 | && (get_wc = (RealGetWindowClassA_proc) GetProcAddress (user32, "RealGetWind
> owClassA")))
> | ^
Please try the below patch instead of the previous one:
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 2cf90f4..ddfe19f 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -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 */
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Wed, 30 Apr 2025 11:18:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
MAN ONE <pRoMMMModE <at> outlook.com>
:
bug acknowledged by developer.
(Wed, 30 Apr 2025 11:18:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 78160-done <at> debbugs.gnu.org (full text, mbox):
> From: MAN ONE <pRoMMMModE <at> outlook.com>
> CC: "78160 <at> debbugs.gnu.org" <78160 <at> debbugs.gnu.org>
> Date: Wed, 30 Apr 2025 11:02:26 +0000
> msip_labels:
>
> The second patch produce no compilation error or warnings, emacsclient.exe and emacsclientw.exe also working, I think the second patch does the trick.
Thanks, installed on both the emacs-30 and the master branch, and
closing this bug.
As for the other warnings, feel free to submit a separate bug report
with them, so we could consider how and on which branch to fix them.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78160
; Package
emacs
.
(Wed, 30 Apr 2025 14:08:04 GMT)
Full text and
rfc822 format available.
Message #19 received at 78160 <at> debbugs.gnu.org (full text, mbox):
Thanks, the patch solved the compilation error, and the compiled binary seems working fine.
However GCC also output some warnings ( actually GCC output a LOT of warnings, I just gonna paste warnings that only relate to the patch.)
make[2]: Entering directory '/e/home/repo/emacs/lib-src'
CC ntlib.o
CCLD etags.exe
CCLD emacsclient.exe
emacsclient.c: In function 'w32_give_focus':
emacsclient.c:1801:17: warning: cast between incompatible function types from 'FARPROC' {a
ka 'long long int (*)(void)'} to 'BOOL (*)(DWORD)' {aka 'int (*)(long unsigned int)'} [-Wc
ast-function-type]
1801 | if ((set_fg = (AllowSetForegroundWindow_proc) GetProcAddress (user32, "AllowSetF
oregroundWindow"))
| ^
emacsclient.c:1802:20: warning: cast between incompatible function types from 'FARPROC' {a
ka 'long long int (*)(void)'} to 'UINT (*)(struct HWND__ *, CHAR *, UINT)' {aka 'unsigned
int (*)(struct HWND__ *, char *, unsigned int)'} [-Wcast-function-type]
1802 | && (get_wc = (RealGetWindowClassA_proc) GetProcAddress (user32, "RealGetWind
owClassA")))
| ^
RC emacsclient.res
CCLD emacsclientw.exe
emacsclient.c: In function 'w32_give_focus':
emacsclient.c:1801:17: warning: cast between incompatible function types from 'FARPROC' {a
ka 'long long int (*)(void)'} to 'BOOL (*)(DWORD)' {aka 'int (*)(long unsigned int)'} [-Wc
ast-function-type]
1801 | if ((set_fg = (AllowSetForegroundWindow_proc) GetProcAddress (user32, "AllowSetF
oregroundWindow"))
| ^
emacsclient.c:1802:20: warning: cast between incompatible function types from 'FARPROC' {a
ka 'long long int (*)(void)'} to 'UINT (*)(struct HWND__ *, CHAR *, UINT)' {aka 'unsigned
int (*)(struct HWND__ *, char *, unsigned int)'} [-Wcast-function-type]
1802 | && (get_wc = (RealGetWindowClassA_proc) GetProcAddress (user32, "RealGetWind
owClassA")))
| ^
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78160
; Package
emacs
.
(Wed, 30 Apr 2025 14:08:05 GMT)
Full text and
rfc822 format available.
Message #22 received at 78160 <at> debbugs.gnu.org (full text, mbox):
The second patch produce no compilation error or warnings, emacsclient.exe and emacsclientw.exe also working, I think the second patch does the trick.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 29 May 2025 11:24:20 GMT)
Full text and
rfc822 format available.
This bug report was last modified 23 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.