]> git.ozlabs.org Git - ccan/blobdiff - ccan/cast/test/compile_fail-cast_const2.c
base64: fix for unsigned chars (e.g. ARM).
[ccan] / ccan / cast / test / compile_fail-cast_const2.c
index 88df4b7a853168141dd3e07fb2bf045fe41c9874..b780f5282f15f1da9ca6c2c03e09826cbccab199 100644 (file)
@@ -1,17 +1,29 @@
 #include <ccan/cast/cast.h>
 #include <stdlib.h>
 
-int main(int argc, char *argv[])
+/* Note: this *isn't* sizeof(char) on all platforms. */
+struct char_struct {
+       char c;
+};
+
+int main(void)
 {
        char **uc;
-       const 
+       const
 #ifdef FAIL
-               int
+               struct char_struct
 #else
                char
 #endif
                **p = NULL;
 
        uc = cast_const2(char **, p);
+       (void) uc; /* Suppress unused-but-set-variable warning. */
        return 0;
 }
+
+#ifdef FAIL
+#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
+#error "Unfortunately we don't fail if cast_const can only use size"
+#endif
+#endif