]> git.ozlabs.org Git - ccan/blob - ccan/tlist/test/compile_fail-tlist_for_each.c
tlist: remove type arg from tlist_top(), tlist_tail()
[ccan] / ccan / tlist / test / compile_fail-tlist_for_each.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;
24 #else
25         struct child *c;
26 #endif
27
28         tlist_init(&children);
29         tlist_add(&children, &child, list);
30
31         tlist_for_each(&children, c, list)
32                 (void) c; /* Suppress unused-but-set-variable warning. */
33         return 0;
34 }