]> git.ozlabs.org Git - ccan/blob - ccan/tlist/test/compile_fail-tlist_top.c
tdb2: tdb_foreach()
[ccan] / ccan / tlist / test / compile_fail-tlist_top.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         void *c;
20
21         tlist_init(&children);
22         tlist_add(&children, &child, list);
23
24         c = tlist_top(&children,
25 #ifdef FAIL
26 #if !HAVE_FLEXIBLE_ARRAY_MEMBER
27 #error Need flexible array members to check type
28 #endif
29                       struct cousin,
30 #else
31                       struct child,
32 #endif
33                       list);
34         (void) c; /* Suppress unused-but-set-variable warning. */
35         return 0;
36 }