compiler: RETURNS_NONNULL macro
[ccan] / ccan / typesafe_cb / test / compile_fail-typesafe_cb_cast.c
1 #include <ccan/typesafe_cb/typesafe_cb.h>
2
3 void _set_some_value(void *val);
4
5 void _set_some_value(void *val)
6 {
7         (void)val;
8 }
9
10 #define set_some_value(expr)                                            \
11         _set_some_value(typesafe_cb_cast(void *, unsigned long, (expr)))
12
13 int main(void)
14 {
15 #ifdef FAIL
16         int x = 0;
17         set_some_value(x);
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         void *p = 0;
23         set_some_value(p);
24 #endif
25         return 0;
26 }