Add stddef.h include for offsetof
[babeltrace.git] / include / babeltrace / compiler.h
1 #ifndef _BABELTRACE_COMPILER_H
2 #define _BABELTRACE_COMPILER_H
3
4 #include <stddef.h> /* for offsetof */
5
6 #define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
7
8 #ifndef container_of
9 #define container_of(ptr, type, member) \
10 ({ \
11 const typeof(((type *)NULL)->member) * __ptr = (ptr); \
12 (type *)((char *)__ptr - offsetof(type, member)); \
13 })
14 #endif
15
16 #endif /* _BABELTRACE_COMPILER_H */
This page took 0.029949 seconds and 4 git commands to generate.