]> git.ozlabs.org Git - ccan/blob - ccan/tcon/test/compile_ok-container.c
base64: fix for unsigned chars (e.g. ARM).
[ccan] / ccan / tcon / test / compile_ok-container.c
1 #include <stdlib.h>
2
3 #include <ccan/tcon/tcon.h>
4 #include <ccan/build_assert/build_assert.h>
5 #include <ccan/tap/tap.h>
6
7 struct inner {
8         int inner_val;
9 };
10
11 struct outer {
12         int outer_val;
13         struct inner inner;
14 };
15
16 struct info_base {
17         char *infop;
18 };
19
20 struct info_tcon {
21         struct info_base base;
22         TCON(TCON_CONTAINER(fi, struct outer, inner));
23 };
24
25 int main(void)
26 {
27         /* Const should work! */
28         const struct outer *ovar = NULL;
29         struct outer *o;
30         struct info_tcon info;
31
32         o = tcon_container_of(&info, fi, &ovar->inner);
33         return (o == ovar);
34 }
35