]> git.ozlabs.org Git - ccan/blob - ccan/typesafe_cb/test/compile_fail-typesafe_cb_postargs.c
tdb2: tdb_set_attribute, tdb_unset_attribute and tdb_get_attribute
[ccan] / ccan / typesafe_cb / test / compile_fail-typesafe_cb_postargs.c
1 #include <ccan/typesafe_cb/typesafe_cb.h>
2 #include <stdlib.h>
3
4 static void _register_callback(void (*cb)(void *arg, int x), void *arg)
5 {
6 }
7 #define register_callback(cb, arg)                              \
8         _register_callback(typesafe_cb_postargs(void, void *, (cb), (arg), int), (arg))
9
10 static void my_callback(char *p, int x)
11 {
12 }
13
14 int main(int argc, char *argv[])
15 {
16 #ifdef FAIL
17         int *p;
18 #if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
19 #error "Unfortunately we don't fail if typesafe_cb_cast is a noop."
20 #endif
21 #else
22         char *p;
23 #endif
24         p = NULL;
25         register_callback(my_callback, p);
26         return 0;
27 }