[PATCH] include: use a better offsetof()

Marcus Meissner marcus at jet.franken.de
Tue Apr 14 17:25:32 CDT 2009


Hi,

gcc TRUNK (which will become 4.5) does not like
our FIELD_OFFSET macro in some cases, like in dlls/gdi32/tests/generated.c.

So just use "offsetof" if present, according to C89 this is
always a macro.

Ciao, Marcus
---
 include/winnt.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/include/winnt.h b/include/winnt.h
index abcc502..132bc64 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -604,8 +604,12 @@ typedef struct _MEMORY_BASIC_INFORMATION
 #define MAXWORD       0xffff
 #define MAXDWORD      0xffffffff
 
-#define FIELD_OFFSET(type, field) \
+#ifdef offsetof
+# define FIELD_OFFSET(type, field) offsetof(type,field)
+#else
+# define FIELD_OFFSET(type, field) \
   ((LONG)(INT_PTR)&(((type *)0)->field))
+#endif
 
 #define CONTAINING_RECORD(address, type, field) \
   ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
-- 
1.5.6



More information about the wine-patches mailing list