]> git.ozlabs.org Git - ccan/blob - ccan/typesafe_cb/test/compile_fail-cast_if_type-promotable.c
Merge Makefile rewrite into master
[ccan] / ccan / typesafe_cb / test / compile_fail-cast_if_type-promotable.c
1 #include <ccan/typesafe_cb/typesafe_cb.h>
2 #include <stdbool.h>
3
4 static void _set_some_value(void *val)
5 {
6         (void)val;
7 }
8
9 #define set_some_value(expr)                                            \
10         _set_some_value(typesafe_cb_cast(void *, long, (expr)))
11
12 int main(void)
13 {
14 #ifdef FAIL
15         bool x = 0;
16 #if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
17 #error "Unfortunately we don't fail if typesafe_cb_cast is a noop."
18 #endif
19 #else
20         long x = 0;
21 #endif
22         set_some_value(x);
23         return 0;
24 }