array_size: make sure tests work even without GCC features.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 22 Mar 2011 01:36:40 +0000 (12:06 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 22 Mar 2011 01:36:40 +0000 (12:06 +1030)
In this case, "work" means "fail to compile cleanly".

ccan/array_size/test/compile_fail-function-param.c

index 283646f871a771af54893fb4de913e1a7b43340f..cb64d984247bc0a374c4d454968af5df8882958f 100644 (file)
@@ -10,6 +10,9 @@ int check_parameter(const struct foo array[4])
 {
 #ifdef FAIL
        return (ARRAY_SIZE(array) == 4);
+#if !HAVE_TYPEOF || !HAVE_BUILTIN_TYPES_COMPATIBLE_P
+#error "Unfortunately we don't fail if _array_size_chk is a noop."
+#endif
 #else
        return sizeof(array) == 4 * sizeof(struct foo);
 #endif