X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=typesafe_cb%2Ftest%2Fcompile_fail-typesafe_cb-int.c;fp=typesafe_cb%2Ftest%2Fcompile_fail-typesafe_cb-int.c;h=54d0e7bac3a36094303555d699775590d39e6eb7;hb=bd9f392599277acd2404688d034aa98b652ee1b7;hp=0000000000000000000000000000000000000000;hpb=246bde098d4f5ac212840a41b740297dd94e1135;p=ccan diff --git a/typesafe_cb/test/compile_fail-typesafe_cb-int.c b/typesafe_cb/test/compile_fail-typesafe_cb-int.c new file mode 100644 index 00000000..54d0e7ba --- /dev/null +++ b/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; +}