X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fstr%2Ftest%2Fcompile_fail-isspace.c;fp=ccan%2Fstr%2Ftest%2Fcompile_fail-isspace.c;h=c94c49e4893cc506c30df90bf4f217b7c593f50d;hb=ecea073699c60fd5aab9e3955f59a7042d637b68;hp=0000000000000000000000000000000000000000;hpb=3f4e83d8ac847d6bf0c20e88cdbca535e842a97b;p=ccan diff --git a/ccan/str/test/compile_fail-isspace.c b/ccan/str/test/compile_fail-isspace.c new file mode 100644 index 00000000..c94c49e4 --- /dev/null +++ b/ccan/str/test/compile_fail-isspace.c @@ -0,0 +1,23 @@ +#define CCAN_STR_DEBUG 1 +#include + +int main(int argc, char *argv[]) +{ +#ifdef FAIL +#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF +#error We need typeof to check isspace. +#endif + char +#else + unsigned char +#endif + c = argv[0][0]; + +#ifdef FAIL + /* Fake fail on unsigned char platforms. */ + c = 255; + BUILD_ASSERT(c < 0); +#endif + + return isspace(c); +}