Print this page
3373 gcc >= 4.5 concerns about offsetof()
Portions contributed by: Igor Pashev <pashev.igor@gmail.com>

@@ -368,11 +368,15 @@
 
 /* avoid any possibility of clashing with <stddef.h> version */
 #if (defined(_KERNEL) || defined(_FAKE_KERNEL)) && !defined(_KMEMUSER)
 
 #if !defined(offsetof)
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#define offsetof(s, m) __builtin_offsetof(s, m)
+#else
 #define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))
+#endif
 #endif /* !offsetof */
 
 #define container_of(m, s, name)                        \
         (void *)((uintptr_t)(m) - (uintptr_t)offsetof(s, name))