]> git.ozlabs.org Git - ccan/blobdiff - ccan/cast/test/compile_fail-cast_const3.c
io: add io_is_idle().
[ccan] / ccan / cast / test / compile_fail-cast_const3.c
index 6232c863db040e9ad6e23b2e3a6ac8acad54af97..e958e2dde5b61c485f63be5008c3ac5137733ecc 100644 (file)
@@ -1,17 +1,29 @@
 #include <ccan/cast/cast.h>
 #include <stdlib.h>
 
+/* Note: this *isn't* sizeof(char) on all platforms. */
+struct char_struct {
+       char c;
+};
+
 int main(int argc, char *argv[])
 {
        char ***uc;
-       const 
+       const
 #ifdef FAIL
-               int
+               struct char_struct
 #else
                char
 #endif
                ***p = NULL;
 
        uc = cast_const3(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