X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftcon%2Ftest%2Fcompile_ok-sizeof.c;fp=ccan%2Ftcon%2Ftest%2Fcompile_ok-sizeof.c;h=64ccc136ea53ed86a2fc55ba839862bdbb6da72c;hb=cc3db07ecc15f3e1e556387d82318697956e8e0c;hp=0000000000000000000000000000000000000000;hpb=43992de4769085b3aba0fd9c167a85ad14e771d2;p=ccan diff --git a/ccan/tcon/test/compile_ok-sizeof.c b/ccan/tcon/test/compile_ok-sizeof.c new file mode 100644 index 00000000..64ccc136 --- /dev/null +++ b/ccan/tcon/test/compile_ok-sizeof.c @@ -0,0 +1,35 @@ +#include +#include +#include + +struct container { + void *p; +}; + +struct int_container { + struct container raw; + TCON(int tc); +}; + +struct charp_and_int_container { + struct container raw; + TCON(int tc1; char *tc2); +}; + +int main(int argc, char *argv[]) +{ + struct int_container icon; + struct charp_and_int_container cicon; + TCON_WRAP(struct container, int tc) iconw; + TCON_WRAP(struct container, int tc1; char *tc2) ciconw; + + BUILD_ASSERT(tcon_sizeof(&icon, tc) == sizeof(int)); + BUILD_ASSERT(tcon_sizeof(&cicon, tc1) == sizeof(int)); + BUILD_ASSERT(tcon_sizeof(&cicon, tc2) == sizeof(char *)); + + BUILD_ASSERT(tcon_sizeof(&iconw, tc) == sizeof(int)); + BUILD_ASSERT(tcon_sizeof(&ciconw, tc1) == sizeof(int)); + BUILD_ASSERT(tcon_sizeof(&ciconw, tc2) == sizeof(char *)); + + return 0; +}