First cut, some hacks, three simple modules.
[ccan] / container_of / container_of.h
1 #ifndef CCAN_CONTAINER_OF_H
2 #define CCAN_CONTAINER_OF_H
3 #include <stddef.h>
4
5 #include "config.h"
6 #include "check_type/check_type.h"
7
8 #define container_of(member_ptr, containing_type, member)               \
9          ((containing_type *)                                           \
10           ((char *)(member_ptr) - offsetof(containing_type, member))    \
11           - check_types_match(*(member_ptr), ((containing_type *)0)->member))
12
13
14 #endif /* CCAN_CONTAINER_OF_H */