The LeaseObtained and LeaseExpires fields of the IP_ADAPTER_INFO
structure are declared as time_t, which on 32-bit target can be either
32-bit or 64-bit, but the 32-bit version of the GetAdaptersInfo
function requires these fields to be 32-bit.

MSDN recommends defining the _USE_32BIT_TIME_T macro in translation
units that use the IP_ADAPTER_INFO structure.

I don't feel that's the right approach.

IMHO we should just declare these fields as __time32_t or __time64_t
depending on the target bitness.
From 2ebd2109683a70750d42d357aa57707da58612f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mateusz=20Wajch=C4=99prze=C5=82=C3=B3=C5=BC?=
 <mati271...@gmail.com>
Date: Sun, 12 Feb 2023 14:54:53 +0100
Subject: [PATCH] headers: Fix ambigous declaration of the LeaseObtained and
 LeaseExpires fields of the IP_ADAPTER_INFO structure in iptypes.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

32-bit version of the GetAdaptersInfo function requires these fields to be 
32-bit

Signed-off-by: Mateusz Wajchęprzełóż <mati271...@gmail.com>
---
 mingw-w64-headers/include/iptypes.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-headers/include/iptypes.h 
b/mingw-w64-headers/include/iptypes.h
index d044a83..b6b719d 100644
--- a/mingw-w64-headers/include/iptypes.h
+++ b/mingw-w64-headers/include/iptypes.h
@@ -60,8 +60,13 @@ extern "C" {
     WINBOOL HaveWins;
     IP_ADDR_STRING PrimaryWinsServer;
     IP_ADDR_STRING SecondaryWinsServer;
-    time_t LeaseObtained;
-    time_t LeaseExpires;
+#ifdef _WIN64
+    __time64_t LeaseObtained;
+    __time64_t LeaseExpires;
+#else
+    __time32_t LeaseObtained;
+    __time32_t LeaseExpires;
+#endif
   } IP_ADAPTER_INFO,*PIP_ADAPTER_INFO;
 
 #ifdef _WINSOCK2API_
-- 
2.35.1.windows.2

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to