]> git.ozlabs.org Git - ccan/blob - ccan/cast/test/compile_fail-cast_signed-sizesame.c
tally: fix FreeBSD compile, memleak in tests.
[ccan] / ccan / cast / test / compile_fail-cast_signed-sizesame.c
1 #include <ccan/cast/cast.h>
2 #include <stdlib.h>
3
4 /* Note: this *isn't* sizeof(char) on all platforms. */
5 struct char_struct {
6         char c;
7 };
8
9 int main(int argc, char *argv[])
10 {
11         unsigned char *uc;
12 #ifdef FAIL
13         struct char_struct
14 #else
15         char
16 #endif
17                 *p = NULL;
18
19         uc = cast_signed(unsigned char *, p);
20
21         (void) uc; /* Suppress unused-but-set-variable warning. */
22         return 0;
23 }
24
25 #ifdef FAIL
26 #if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
27 #error "Unfortunately we don't fail if cast_signed can only use size"
28 #endif
29 #endif