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