From 8a2839510236d0b31037b4e1e2ea92ef1148ac21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 13 Jan 2018 20:54:57 +0100 Subject: [PATCH] fix-up PRINTF to use PUTS when no variable args are given --- debug.c | 2 +- debug.h | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/debug.c b/debug.c index db31482..9bc2af2 100644 --- a/debug.c +++ b/debug.c @@ -8,7 +8,7 @@ #if USE_DEBUG_UART // debug printf -int PRINTF(const char *format, ...) +int _DO_PRINTF(const char *format, ...) { va_list args; int len; diff --git a/debug.h b/debug.h index 8091e52..ddaa470 100644 --- a/debug.h +++ b/debug.h @@ -11,12 +11,20 @@ #if USE_DEBUG_UART -int PRINTF(const char *format, ...) __attribute__((format(printf,1,2))) ; +int _DO_PRINTF(const char *format, ...) __attribute__((format(printf,1,2))) ; void PUTSN(const char *string, size_t len); int PUTS(const char *string); void PUTNL(void); int PUTCHAR(int ch); +#define PRINTF(format, ...) do { \ + if (VA_ARG_COUNT(__VA_ARGS__) == 0) { \ + PUTS(format); \ + } else { \ + _DO_PRINTF(format, ##__VA_ARGS__); \ + } \ + } while (0) + #define dbg(format, ...) do { \ if (VA_ARG_COUNT(__VA_ARGS__) == 0) { \ PUTS(format); \