The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxcfs/pull/302
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Originally, the compiler complained: macro.h:7:25: error: expected expression before ')' token __func__, __VA_ARGS__); The reason is that GCC wouldn't abandon `,` when `__VA_ARGS__` is empty. For emaple: #define eprintf(format, ...) fprintf (stderr, format, __VA_ARGS__) eprintf("success!\n", ); → fprintf(stderr, "success!\n", ); According to GCC doc, it's okay when adding `##` before `__VA_ARGS__`: #define eprintf(format, ...) fprintf (stderr, format, ##__VA_ARGS__) eprintf ("success!\n") → fprintf(stderr, "success!\n");
From 2a94c281e34f53867ed75fb4c3d00e7c814287d5 Mon Sep 17 00:00:00 2001 From: river <ri...@vvl.me> Date: Mon, 26 Aug 2019 18:01:12 +0800 Subject: [PATCH] macro: fix lxcfs_{error,debug,v} build error when __VA_ARGS__ is empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Originally, the compiler complained: macro.h:7:25: error: expected expression before ')' token __func__, __VA_ARGS__); The reason is that GCC wouldn't abandon `,` when `__VA_ARGS__` is empty. For emaple: #define eprintf(format, ...) fprintf (stderr, format, __VA_ARGS__) eprintf("success!\n", ); → fprintf(stderr, "success!\n", ); According to GCC doc, it's okay when adding `##` before `__VA_ARGS__`: #define eprintf(format, ...) fprintf (stderr, format, ##__VA_ARGS__) eprintf ("success!\n") → fprintf(stderr, "success!\n"); --- macro.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/macro.h b/macro.h index 7213b8f..3e9ef82 100644 --- a/macro.h +++ b/macro.h @@ -4,19 +4,19 @@ #define lxcfs_debug_stream(stream, format, ...) \ do { \ fprintf(stream, "%s: %d: %s: " format, __FILE__, __LINE__, \ - __func__, __VA_ARGS__); \ + __func__, ##__VA_ARGS__); \ } while (false) -#define lxcfs_error(format, ...) lxcfs_debug_stream(stderr, format, __VA_ARGS__) +#define lxcfs_error(format, ...) lxcfs_debug_stream(stderr, format, ##__VA_ARGS__) #ifdef DEBUG -#define lxcfs_debug(format, ...) lxcfs_error(format, __VA_ARGS__) +#define lxcfs_debug(format, ...) lxcfs_error(format, ##__VA_ARGS__) #else #define lxcfs_debug(format, ...) #endif /* DEBUG */ #ifdef VERBOSE -#define lxcfs_v(format, ...) lxcfs_error(format, __VA_ARGS__); +#define lxcfs_v(format, ...) lxcfs_error(format, ##__VA_ARGS__); #else #define lxcfs_v(format, ...) #endif /* VERBOSE */
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel