]> www.ginac.de Git - cln.git/blob - src/base/cl_offsetof.h
Fix compilation with clang.
[cln.git] / src / base / cl_offsetof.h
1 // offsetof() and friends
2
3 // <stddef.h> in GCC 3.0/3.1 has the obscure property of redefining
4 // offsetof every time it is included, not just the first time.
5 // Therefore we do the same thing here, and make sure that this file
6 // gets included after each include of <stddef.h>.
7
8 #undef offsetof
9 #if defined(__GNUG__)
10   #define offsetof(type,ident)  ((long)&(((type*)1)->ident)-1)
11 #else
12   #define offsetof(type,ident)  ((long)&(((type*)0)->ident))
13 #endif
14
15 #ifndef _CL_OFFSETOF_H
16 #define _CL_OFFSETOF_H
17
18 #define offsetofa(type,ident)  offsetof(type,ident[0])
19
20 #endif /* _CL_OFFSETOF_H */