tlist: typesafe variant of list module.
[ccan] / ccan / tlist / test / compile_fail-tlist_for_each_safe.c
1 #include <ccan/tlist/tlist.h>
2
3 TLIST_TYPE(children, struct child);
4
5 struct child {
6         const char *name;
7         struct list_node list;
8 };
9
10 struct cousin {
11         const char *name;
12         struct list_node list;
13 };
14
15 int main(int argc, char *argv[])
16 {
17         struct tlist_children children;
18         struct child child = { "child" };
19 #ifdef FAIL
20 #if !HAVE_FLEXIBLE_ARRAY_MEMBER
21 #error Need flexible array members to check type
22 #endif
23         struct cousin *c, *n;
24 #else
25         struct child *c, *n;
26 #endif
27
28         tlist_init(&children);
29         tlist_add(&children, &child, list);
30
31         tlist_for_each_safe(&children, c, n, list);
32         return 0;
33 }