Print this page
3373 gcc >= 4.5 concerns about offsetof()

@@ -25,12 +25,10 @@
  */
 
 #ifndef _SYS_ECPPVAR_H
 #define _SYS_ECPPVAR_H
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
-
 #include <sys/note.h>
 
 #ifdef  __cplusplus
 extern "C" {
 #endif

@@ -511,11 +509,15 @@
 
 /*
  * Other useful macros
  */
 #define NELEM(a)        (sizeof (a) / sizeof (*(a)))
+#if defined(__GNUC__)
+#define offsetof(s, m)  __builtin_offsetof(s, m)
+#else
 #define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))
+#endif
 
 #ifdef  __cplusplus
 }
 #endif