X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftcon%2Ftest%2Fcompile_fail-container3w.c;fp=ccan%2Ftcon%2Ftest%2Fcompile_fail-container3w.c;h=6930b436d984c5fe8e833b9cb81efd26304a0df9;hb=0ddea4131eca28437638cdaf9394324fafab33da;hp=0000000000000000000000000000000000000000;hpb=fd48aee6393bda1e4eda9f9e52e6d9f818b77211;p=ccan diff --git a/ccan/tcon/test/compile_fail-container3w.c b/ccan/tcon/test/compile_fail-container3w.c new file mode 100644 index 00000000..6930b436 --- /dev/null +++ b/ccan/tcon/test/compile_fail-container3w.c @@ -0,0 +1,36 @@ +#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 *outerp; +#else + struct outer *outerp; +#endif + + outerp = tcon_container_of(&info, concan, &ovar.inner); + return outerp != NULL; +}