Add stddef.h include for offsetof
[babeltrace.git] / include / babeltrace / compiler.h
CommitLineData
d79865b9
MD
1#ifndef _BABELTRACE_COMPILER_H
2#define _BABELTRACE_COMPILER_H
3
334c0a83
MD
4#include <stddef.h> /* for offsetof */
5
d79865b9
MD
6#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
7
fc93b2bd
MD
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
d79865b9 16#endif /* _BABELTRACE_COMPILER_H */
This page took 0.024305 seconds and 4 git commands to generate.