From bedc16d46d3f64cd368aa2fcc60d5e17981c6990 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 9 Mar 2024 18:32:08 +0200 Subject: [PATCH] [DEVMGR] Add DYNAMIC_FIELD_OFFSET macro This replaces the usage of FIELD_OFFSET for dynamic indexing into array fields. Sadly GCC has broken __builtin_offsetof and they don't seem to intend to fix it. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95942 --- dll/win32/devmgr/precomp.h | 4 +++- dll/win32/devmgr/properties/hwpage.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dll/win32/devmgr/precomp.h b/dll/win32/devmgr/precomp.h index 1ca2f4b1111..2165d4bf12b 100644 --- a/dll/win32/devmgr/precomp.h +++ b/dll/win32/devmgr/precomp.h @@ -76,6 +76,8 @@ OUT LPDWORD lpReboot); #include #include +#define DYNAMIC_FIELD_OFFSET(Type, Field) ((LONG)(LONG_PTR)&(((Type*) 0)->Field)) + //WINE_DEFAULT_DEBUG_CHANNEL(devmgr); -#endif \ No newline at end of file +#endif diff --git a/dll/win32/devmgr/properties/hwpage.cpp b/dll/win32/devmgr/properties/hwpage.cpp index 8fb4161c910..9bd2c7ab05a 100644 --- a/dll/win32/devmgr/properties/hwpage.cpp +++ b/dll/win32/devmgr/properties/hwpage.cpp @@ -1030,8 +1030,8 @@ DeviceCreateHardwarePageEx(IN HWND hWndParent, failure cases! */ hpd = (PHARDWARE_PAGE_DATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - FIELD_OFFSET(HARDWARE_PAGE_DATA, - ClassDevInfo[uNumberOfGuids])); + DYNAMIC_FIELD_OFFSET(HARDWARE_PAGE_DATA, + ClassDevInfo[uNumberOfGuids])); if (hpd != NULL) { HWND hWnd;