X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftcon%2Ftest%2Fcompile_fail-container1w.c;fp=ccan%2Ftcon%2Ftest%2Fcompile_fail-container1w.c;h=0226b68e9f01b9095ce01a50dec0092360407c62;hb=0ddea4131eca28437638cdaf9394324fafab33da;hp=0000000000000000000000000000000000000000;hpb=fd48aee6393bda1e4eda9f9e52e6d9f818b77211;p=ccan diff --git a/ccan/tcon/test/compile_fail-container1w.c b/ccan/tcon/test/compile_fail-container1w.c new file mode 100644 index 00000000..0226b68e --- /dev/null +++ b/ccan/tcon/test/compile_fail-container1w.c @@ -0,0 +1,35 @@ +#include + +#include +#include +#include + +struct inner { + int inner_val; +}; + +struct outer { + int outer_val; + struct inner inner; +}; + +struct info_base { + char *infop; +}; + +int main(int argc, char *argv[]) +{ + TCON_WRAP(struct info_base, + TCON_CONTAINER(concan, struct outer, inner)) info; + struct outer ovar; +#ifdef FAIL +#if !HAVE_TYPEOF +#error We cannot detect type problems without HAVE_TYPEOF +#endif + int *innerp = &ovar.outer_val; +#else + struct inner *innerp = &ovar.inner; +#endif + + return tcon_container_of(&info, concan, innerp) == &ovar; +}