From fa270d92873a7fd595e093eb3c07409e336620c0 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Tue, 7 Aug 2018 14:11:19 -0400 Subject: Hack clang into checking uiFmt format strings --- chat.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'chat.h') diff --git a/chat.h b/chat.h index 3d3586c..47a7e1e 100644 --- a/chat.h +++ b/chat.h @@ -45,10 +45,18 @@ void uiRead(void); void uiTopic(const wchar_t *topic); void uiTopicStr(const char *topic); void uiLog(const wchar_t *line); - -//__attribute__((format(printf, 1, 2))) void uiFmt(const wchar_t *format, ...); +// HACK: clang won't check wchar_t *format strings. +#ifdef NDEBUG +#define uiFmt(format, ...) uiFmt(L##format, __VA_ARGS__) +#else +#define uiFmt(format, ...) do { \ + snprintf(NULL, 0, format, __VA_ARGS__); \ + uiFmt(L##format, __VA_ARGS__); \ +} while(0) +#endif + void handle(char *line); void input(wchar_t *line); -- cgit 1.4.1-2-gfad0