From 121454c4bd7c39c2d4798e6461e662c1037bb055 Mon Sep 17 00:00:00 2001 From: "Li, Fei1" Date: Tue, 6 Nov 2018 23:43:47 +0800 Subject: [PATCH] hv: fix a minor bug of static checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a macro is expanded, the two tokens on either side of each ‘##’ operator are combined into a single token, which then replaces the ‘##’ and the two original tokens in the macro expansion. So we need use CAT__ to expand the __LINE__ MACRO and use CAT_ to combine the expaneded MACRO. Tracked-on: #1750 Signed-off-by: Li, Fei1 Acked-by: Anthony Xu --- hypervisor/arch/x86/static_checks.c | 3 ++- hypervisor/common/static_checks.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hypervisor/arch/x86/static_checks.c b/hypervisor/arch/x86/static_checks.c index 4ab1b7d1d..03c72d624 100644 --- a/hypervisor/arch/x86/static_checks.c +++ b/hypervisor/arch/x86/static_checks.c @@ -6,7 +6,8 @@ #include #include -#define CAT_(A,B) A ## B +#define CAT__(A,B) A ## B +#define CAT_(A,B) CAT__(A,B) #define CTASSERT(expr) \ typedef int CAT_(CTA_DummyType,__LINE__)[(expr) ? 1 : -1] diff --git a/hypervisor/common/static_checks.c b/hypervisor/common/static_checks.c index 7c3692ffd..c194d0088 100644 --- a/hypervisor/common/static_checks.c +++ b/hypervisor/common/static_checks.c @@ -5,7 +5,8 @@ */ #include -#define CAT_(A,B) A ## B +#define CAT__(A,B) A ## B +#define CAT_(A,B) CAT__(A,B) #define CTASSERT(expr) \ typedef int CAT_(CTA_DummyType,__LINE__)[(expr) ? 1 : -1]