]> www.ginac.de Git - cln.git/blobdiff - src/base/cl_offsetof.h
Avoid g++-3.1 offsetof warnings.
[cln.git] / src / base / cl_offsetof.h
index 319233448d0ff62439f4831b3d57682ed1cb677f..89ddaf272e7657e35694ddc740e787f332b01bfd 100644 (file)
@@ -1,7 +1,9 @@
 // offsetof() and friends
 
-#ifndef _CL_OFFSETOF_H
-#define _CL_OFFSETOF_H
+// <stddef.h> in GCC 3.0/3.1 has the obscure property of redefining
+// offsetof every time it is included, not just the first time.
+// Therefore we do the same thing here, and make sure that this file
+// gets included after each include of <stddef.h>.
 
 #undef offsetof
 #if defined(__GNUG__)
@@ -9,6 +11,10 @@
 #else
   #define offsetof(type,ident)  ((long)&(((type*)0)->ident))
 #endif
+
+#ifndef _CL_OFFSETOF_H
+#define _CL_OFFSETOF_H
+
 #define offsetofa(type,ident)  offsetof(type,ident[0])
 
 #endif /* _CL_OFFSETOF_H */