X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fasearch%2Ftest%2Fcompile_fail-return-value-const.c;fp=ccan%2Fasearch%2Ftest%2Fcompile_fail-return-value-const.c;h=2edee935012ff2c2352710e9d88120a962f6ab47;hp=0000000000000000000000000000000000000000;hb=93d1e1063c6b5599ab334398234d2de05c1236e8;hpb=c10aab24894083ac7ed2c5e349a2767457314982 diff --git a/ccan/asearch/test/compile_fail-return-value-const.c b/ccan/asearch/test/compile_fail-return-value-const.c new file mode 100644 index 00000000..2edee935 --- /dev/null +++ b/ccan/asearch/test/compile_fail-return-value-const.c @@ -0,0 +1,25 @@ +#include +#include +#include + +static int cmp(const char *key, const char *const *elem) +{ + return strcmp(key, *elem); +} + +int main(void) +{ + const char key[] = "key"; + const char *elems[] = { "a", "big", "list", "of", "things" }; + +#ifdef FAIL + char **p; +#if !HAVE_TYPEOF +#error "Unfortunately we don't fail if no typeof." +#endif +#else + const char **p; +#endif + p = asearch(key, elems, ARRAY_SIZE(elems), cmp); + return p ? 0 : 1; +}