Print this page
3373 gcc >= 4.5 concerns about offsetof()
@@ -24,12 +24,10 @@
*/
#ifndef _SA_STDDEF_H
#define _SA_STDDEF_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Exported interfaces for standalone's subset of libc's <stddef.h>.
* All standalone code *must* use this header rather than libc's.
*/
@@ -40,11 +38,15 @@
#ifndef NULL
#define NULL 0
#endif
#ifndef offsetof
-#define offsetof(s, m) (size_t)(&(((s *)0)->m))
+#if defined(__GNUC__)
+#define offsetof(s, m) __builtin_offsetof(s, m)
+#else
+#define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
+#endif
#endif
#ifdef __cplusplus
}
#endif