]> git.ozlabs.org Git - ccan/blob - ccan/tlist2/test/compile_fail-tlist_for_each_safe_2.c
tlist2: a alternate to tlist that encodes the member offset into the container type
[ccan] / ccan / tlist2 / test / compile_fail-tlist_for_each_safe_2.c
1 #include <ccan/tlist2/tlist2.h>
2
3 struct child {
4         const char *name;
5         struct list_node list;
6 };
7
8 struct cousin {
9         const char *name;
10         struct list_node list;
11 };
12
13 int main(int argc, char *argv[])
14 {
15         TLIST2(struct child, list) children;
16         struct child child = { "child" };
17 #ifdef FAIL
18 #if !HAVE_FLEXIBLE_ARRAY_MEMBER
19 #error Need flexible array members to check type
20 #endif
21         struct cousin *c, *n;
22 #else
23         struct child *c, *n;
24 #endif
25
26         tlist2_init(&children);
27         tlist2_add(&children, &child);
28
29         tlist2_for_each_safe(&children, c, n);
30         return 0;
31 }