Hi Eli,

Eli Zaretskii <e...@gnu.org> writes:

> However, that header is not really needed here because the
> signature of the GetTickCount64 function, which boot-time-aux.h now
> calls, is completely defined in boot-time-aux.h:
>
>   typedef ULONGLONG (WINAPI * GetTickCount64FuncType) (void);
[...]
> So I think the Gnulib code should be amended not to include
> sysinfoapi.h.  For the time being I made a local change in Emacs, to
> be able to build the master branch with MinGW, but I don't think it's
> an Emacs-specific issue.

Thanks for the report.

This code was a backup method for getting the boot time on Windows that
I added recently. On my system #include <windows.h> includes <winbase.h>
which then includes <sysinfoapi.h> unconditionally. Therefore you are
correct that there is no need to include it. I've applied the attached
patch in Gnulib fixing this.

Were you using an older Windows version perhaps? For older systems where
the function isn't declared in headers (_WIN32_WINNT < _WIN32_WINNT_VISTA)
the dll is loaded and it tries to get the function address from there.
Note that the line of code you sent is a typedef not a declaration. :)

Collin

>From c41b3f92e3b0e9bd42d0ac05d80f3d23b00b28d2 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 4 Jun 2024 11:21:04 -0700
Subject: [PATCH] boot-time, readutmp: Fix missing MinGW include (regr.
 2024-05-24).

Reported by Eli Zaretskii in:
<https://lists.gnu.org/archive/html/bug-gnulib/2024-06/msg00044.html>.

* lib/boot-time.c [_WIN32 && !__CYGWIN__]: Remove unnecessary
<sysinfoapi.h> include. Some systems do not have this header and
<windows.h> should have the correct declarations.
* lib/readutmp.c [_WIN32 && !__CYGWIN__]: Likewise.
---
 ChangeLog       | 10 ++++++++++
 lib/boot-time.c |  1 -
 lib/readutmp.c  |  1 -
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 787edff23d..1200ec0ec8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-06-04  Collin Funk  <collin.fu...@gmail.com>
+
+	boot-time, readutmp: Fix missing MinGW include (regr. 2024-05-24).
+	Reported by Eli Zaretskii in:
+	<https://lists.gnu.org/archive/html/bug-gnulib/2024-06/msg00044.html>.
+	* lib/boot-time.c [_WIN32 && !__CYGWIN__]: Remove unnecessary
+	<sysinfoapi.h> include. Some systems do not have this header and
+	<windows.h> should have the correct declarations.
+	* lib/readutmp.c [_WIN32 && !__CYGWIN__]: Likewise.
+
 2024-06-03  Paul Eggert  <egg...@cs.ucla.edu>
 
 	nstrftime: remove dependency on hard-locale
diff --git a/lib/boot-time.c b/lib/boot-time.c
index 71562dcf75..515fc48069 100644
--- a/lib/boot-time.c
+++ b/lib/boot-time.c
@@ -46,7 +46,6 @@
 #if defined _WIN32 && ! defined __CYGWIN__
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
-# include <sysinfoapi.h>
 # include <sys/time.h>
 #endif
 
diff --git a/lib/readutmp.c b/lib/readutmp.c
index 82b9d4ca33..10d79d1d81 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -54,7 +54,6 @@
 #if defined _WIN32 && ! defined __CYGWIN__
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
-# include <sysinfoapi.h>
 # include <sys/time.h>
 #endif
 
-- 
2.45.1

Reply via email to