X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftcon%2Ftest%2Fcompile_fail-container3.c;fp=ccan%2Ftcon%2Ftest%2Fcompile_fail-container3.c;h=97473c8caeb89e2e7455aadabac0482b56eea4d3;hb=0ddea4131eca28437638cdaf9394324fafab33da;hp=0000000000000000000000000000000000000000;hpb=fd48aee6393bda1e4eda9f9e52e6d9f818b77211;p=ccan diff --git a/ccan/tcon/test/compile_fail-container3.c b/ccan/tcon/test/compile_fail-container3.c new file mode 100644 index 00000000..97473c8c --- /dev/null +++ b/ccan/tcon/test/compile_fail-container3.c @@ -0,0 +1,40 @@ +#include + +#include +#include +#include + +struct inner { + int inner_val; +}; + +struct outer { + int outer_val; + struct inner inner; +}; + +struct info_base { + char *infop; +}; + +struct info_tcon { + struct info_base base; + TCON(TCON_CONTAINER(concan, struct outer, inner)); +}; + +int main(int argc, char *argv[]) +{ + struct info_tcon 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; +}