From 893fa4f8da4661c8984aacc4df61237849913f3b Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Fri, 20 May 2016 18:12:41 +0200 Subject: [PATCH] logging.h: Add helpers so the log macros can have just one argument, needed for compilation on visual studio --- include/stlink/logging.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/include/stlink/logging.h b/include/stlink/logging.h index df816ca..81e5f59 100644 --- a/include/stlink/logging.h +++ b/include/stlink/logging.h @@ -20,11 +20,18 @@ enum ugly_loglevel { int ugly_init(int maximum_threshold); int ugly_log(int level, const char *tag, const char *format, ...); -#define DLOG(format, args...) ugly_log(UDEBUG, __FILE__, format, ## args) -#define ILOG(format, args...) ugly_log(UINFO, __FILE__, format, ## args) -#define WLOG(format, args...) ugly_log(UWARN, __FILE__, format, ## args) -#define ELOG(format, args...) ugly_log(UERROR, __FILE__, format, ## args) -#define fatal(format, args...) ugly_log(UFATAL, __FILE__, format, ## args) +/** @todo we need to write this in a more generic way, for now this should compile + on visual studio (See http://stackoverflow.com/a/8673872/1836746) */ +#define DLOG_HELPER(format, ...) ugly_log(UDEBUG, __FILE__, format, __VA_ARGS__) +#define DLOG(...) DLOG_HELPER(__VA_ARGS__, "") +#define ILOG_HELPER(format, ...) ugly_log(UINFO, __FILE__, format, __VA_ARGS__) +#define ILOG(...) ILOG_HELPER(__VA_ARGS__, "") +#define WLOG_HELPER(format, ...) ugly_log(UWARN, __FILE__, format, __VA_ARGS__) +#define WLOG(...) WLOG_HELPER(__VA_ARGS__, "") +#define ELOG_HELPER(format, ...) ugly_log(UERROR, __FILE__, format, __VA_ARGS__) +#define ELOG(...) ELOG_HELPER(__VA_ARGS__, "") +#define fatal_helper(format, ...) ugly_log(UFATAL, __FILE__, format, __VA_ARGS__) +#define fatal(...) fatal_helper(__VA_ARGS__, "") #ifdef __cplusplus }