Commit 8013b215 authored by Sebastian Dröge's avatar Sebastian Dröge

Bug 531900 – Use __builtin_offsetof for G_STRUCT_OFFSET if building

with gcc 4.0 or newer
* glib/gmacros.h: Use __builtin_offsetof for G_STRUCT_OFFSET if
building with gcc 4.0 or newer.

svn path=/trunk/; revision=6996
parent a689811a
2008-06-11 Sebastian Dröge <slomo@circular-chaos.org>
Bug 531900 – Use __builtin_offsetof for G_STRUCT_OFFSET if building
with gcc 4.0 or newer
* glib/gmacros.h: Use __builtin_offsetof for G_STRUCT_OFFSET if
building with gcc 4.0 or newer.
2008-06-11 Tor Lillqvist <tml@novell.com>
* glib/gmain.c
......
......@@ -209,8 +209,15 @@
/* Provide convenience macros for handling structure
* fields through their offsets.
*/
#define G_STRUCT_OFFSET(struct_type, member) \
((glong) ((guint8*) &((struct_type*) 0)->member))
#if defined(__GNUC__) && __GNUC__ >= 4
# define G_STRUCT_OFFSET(struct_type, member) \
((glong) __builtin_offsetof (struct_type, member))
#else
# define G_STRUCT_OFFSET(struct_type, member) \
((glong) ((guint8*) &((struct_type*) 0)->member))
#endif
#define G_STRUCT_MEMBER_P(struct_p, struct_offset) \
((gpointer) ((guint8*) (struct_p) + (glong) (struct_offset)))
#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment