X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftypesafe_cb%2Ftest%2Fcompile_fail-typesafe_cb-int.c;fp=ccan%2Ftypesafe_cb%2Ftest%2Fcompile_fail-typesafe_cb-int.c;h=54d0e7bac3a36094303555d699775590d39e6eb7;hp=0000000000000000000000000000000000000000;hb=650c775ff00cccd03fc84e7789a03c51d9839004;hpb=c8acddea39d222312102952e91c32cfe4dd2cea0 diff --git a/ccan/typesafe_cb/test/compile_fail-typesafe_cb-int.c b/ccan/typesafe_cb/test/compile_fail-typesafe_cb-int.c new file mode 100644 index 00000000..54d0e7ba --- /dev/null +++ b/ccan/typesafe_cb/test/compile_fail-typesafe_cb-int.c @@ -0,0 +1,27 @@ +#include "typesafe_cb/typesafe_cb.h" +#include + +void _callback(void (*fn)(void *arg), void *arg); +void _callback(void (*fn)(void *arg), void *arg) +{ + fn(arg); +} + +/* Callback is set up to warn if arg isn't a pointer (since it won't + * pass cleanly to _callback's second arg. */ +#define callback(fn, arg) \ + _callback(typesafe_cb(void, (fn), (arg)), (arg)) + +void my_callback(int something); +void my_callback(int something) +{ +} + +int main(int argc, char *argv[]) +{ +#ifdef FAIL + /* This fails due to arg, not due to cast. */ + callback(my_callback, 100); +#endif + return 0; +}