]> git.ozlabs.org Git - ccan/blob - ccan/tlist2/test/compile_fail-tlist_top_2.c
tlist2: a alternate to tlist that encodes the member offset into the container type
[ccan] / ccan / tlist2 / test / compile_fail-tlist_top_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         struct cousin *c;
19 #else
20         struct child *c;
21 #endif
22
23         tlist2_init(&children);
24         tlist2_add(&children, &child);
25
26         c = tlist2_top(&children);
27         (void) c; /* Suppress unused-but-set-variable warning. */
28         return 0;
29 }