]> git.ozlabs.org Git - ccan/blob - ccan/bytestring/test/compile_fail-BYTESTRING-2.c
bytestring: Add rational comment to testcase
[ccan] / ccan / bytestring / test / compile_fail-BYTESTRING-2.c
1 #include "config.h"
2
3 #include <stdio.h>
4
5 #include <ccan/bytestring/bytestring.h>
6
7 /*
8  * BYTESTRING() can only be used safely on a literal string (or,
9  * strictly, something whose size can be determined with ARRAY_SIZE().
10  * This checks that it correctly fails to compile if used on a
11  * non-array pointer.
12  */
13 int main(int argc, char *argv[])
14 {
15         struct bytestring bs;
16         const char *x = "abcde";
17
18 #ifdef FAIL
19         bs = BYTESTRING(x);
20 #else
21         bs.len = 0;
22 #endif
23         printf("%zd %s\n", bs.len, x);
24         return 0;
25 }