compiler: RETURNS_NONNULL macro
[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         (void)cb;
7         (void)arg;
8 }
9 #define register_callback(cb, arg)                              \
10         _register_callback(typesafe_cb_postargs(void, void *, (cb), (arg), int), (arg))
11
12 static void my_callback(char *p, int x)
13 {
14         (void)p;
15         (void)x;
16 }
17
18 int main(void)
19 {
20 #ifdef FAIL
21         int *p;
22 #if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
23 #error "Unfortunately we don't fail if typesafe_cb_cast is a noop."
24 #endif
25 #else
26         char *p;
27 #endif
28         p = NULL;
29         register_callback(my_callback, p);
30         return 0;
31 }