aboutsummaryrefslogtreecommitdiff
path: root/ccan/str/test/compile_fail-STR_MAX_CHARS.c
diff options
context:
space:
mode:
Diffstat (limited to 'ccan/str/test/compile_fail-STR_MAX_CHARS.c')
-rw-r--r--ccan/str/test/compile_fail-STR_MAX_CHARS.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/ccan/str/test/compile_fail-STR_MAX_CHARS.c b/ccan/str/test/compile_fail-STR_MAX_CHARS.c
new file mode 100644
index 0000000..74448c1
--- /dev/null
+++ b/ccan/str/test/compile_fail-STR_MAX_CHARS.c
@@ -0,0 +1,23 @@
+#include <ccan/str/str.h>
+
+struct s {
+ int val;
+};
+
+int main(int argc, char *argv[])
+{
+ struct s
+#ifdef FAIL
+#if !HAVE_TYPEOF
+ #error We need typeof to check STR_MAX_CHARS.
+#endif
+#else
+ /* A pointer is OK. */
+ *
+#endif
+ val;
+ char str[STR_MAX_CHARS(val)];
+
+ str[0] = '\0';
+ return str[0] ? 0 : 1;
+}