Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
#if HAVE_TYPEOF
/* Only a simple type can have 0 assigned, so test that. */
#define STR_MAX_CHARS_TCHECK_(type_or_expr) \
#if HAVE_TYPEOF
/* Only a simple type can have 0 assigned, so test that. */
#define STR_MAX_CHARS_TCHECK_(type_or_expr) \
- ({ typeof(type_or_expr) x = 0; (void)x; 0; })
+ (sizeof(({ typeof(type_or_expr) x = 0; x; }))*0)
#else
#define STR_MAX_CHARS_TCHECK_(type_or_expr) 0
#endif
#else
#define STR_MAX_CHARS_TCHECK_(type_or_expr) 0
#endif
--- /dev/null
+#include <ccan/str/str.h>
+
+int main(void)
+{
+ static char str[STR_MAX_CHARS(int)];
+
+ return str[0] ? 0 : 1;
+}