From patchwork Tue Sep 12 22:43:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 813112 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="F7c7ay3A"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xsKbQ2szBz9sNw for ; Wed, 13 Sep 2017 08:44:02 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 57E10B63; Tue, 12 Sep 2017 22:43:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 68EAEB5D for ; Tue, 12 Sep 2017 22:43:57 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 34599E0 for ; Tue, 12 Sep 2017 22:43:57 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id m30so1824130pgn.5 for ; Tue, 12 Sep 2017 15:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=9UE271A54SWRqjVlQG/1cua8fLa/7QmT4vJ93vBFfGc=; b=F7c7ay3AM/F/Hg1oyzWu+n7kISojMxCrZgxKoVgvgCPZSPCuVGIjDOf6CEYEw1QXDN Sc/qcLdyGxWliCO1T/TFhj/YNJgdq2/BuPqadTsxac+XD1m+UqREAT7szlJv+gjzzPS1 3WSk0vQXhYVk8/7pbI9yOYh9U9IflIFNoSX5BLaJEjNE7tBSvoyjIRrnKmYXD4C38ZZ1 ZMgUCk5QaimzHEQA7n8OiKlUd/fN717OSO+7SHhPh1TMyVWAYcPLIUG7IDIPyvpDhZof KB5VroeCbAlT0lirMNKNw4cutHOg8XI61wG/U2zM+XYh0EdG2PbWsJBICS+vLeFcZAdL XGEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9UE271A54SWRqjVlQG/1cua8fLa/7QmT4vJ93vBFfGc=; b=Gz+GaCXstRC46SiauzbDJrPCjWmsmW5DL4imHwJSMwqdrS1K3tE1eEEaYM6X7ogiEg BfBkePx/C/ZXHxGUMCQgYLmbLqwH5D0l2Vv5CPaXpRTmjeQU8yKOLg8UFFa3B5zFTaMC EDg96LPHBB1CM0h/xVd+ep87XY/Jnrb5XWTL/fGKF3WEZD45eiQkNBSJEuZ2m5rm5Fa6 9JO2sutBoySaDFRPSZ71vWSE5j9CfRs5ISEshslDb0rkuU8dtgRmeqCy5fZbRrM0visM 1PkpK6ulqx0sOgWMOHJy1vDW98dM779wUwBkIlh7b3ii1CVdID8rKVj3BE7arioLEdC9 NDoA== X-Gm-Message-State: AHPjjUg5aypx33x1LkQeyEeuc+xCVejBcCeI1VSpQ6qJlcxE9GEhSjP2 CLRdozo4IOMAoPM0/rw= X-Google-Smtp-Source: ADKCNb6BrbgTD7vrH+gsHdHGFrUyh2QTK+DmHOOj3xyDmtEpCWzRK37u7GmvtlJBzYz1IiV4KrYAmQ== X-Received: by 10.98.87.23 with SMTP id l23mr16369974pfb.77.1505256236544; Tue, 12 Sep 2017 15:43:56 -0700 (PDT) Received: from vm-01.eng.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id s4sm8770552pgr.32.2017.09.12.15.43.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Sep 2017 15:43:56 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Tue, 12 Sep 2017 15:43:03 -0700 Message-Id: <1505256183-83048-1-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=0.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] Fix C++ build issue when static_assert() is not available X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This patch prevents compile errors if the C++ compiler does not support C++11 or the support is not enabled. VMWare-BZ: #1953215 Fixes: 994bfc298502 ("Automatically verify that OVS header files work OK in C++ also.") Signed-off-by: Yi-Hung Wei Acked-by: Ben Pfaff --- include/openflow/openflow-common.h | 7 +++++-- include/openvswitch/compiler.h | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/openflow/openflow-common.h b/include/openflow/openflow-common.h index d66551997434..ea6bb41bc15c 100644 --- a/include/openflow/openflow-common.h +++ b/include/openflow/openflow-common.h @@ -59,9 +59,12 @@ #define OFP_ASSERT(EXPR) \ extern int (*build_assert(void))[ sizeof(struct { \ unsigned int build_assert_failed : (EXPR) ? 1 : -1; })] -#else /* __cplusplus */ +#elif __cplusplus >= 201103L #define OFP_ASSERT(EXPR) static_assert(EXPR, "assertion failed") -#endif /* __cplusplus */ +#else /* __cplusplus < 201103L */ +#include +#define OFP_ASSERT BOOST_STATIC_ASSERT +#endif /* __cplusplus < 201103L */ /* Version number: * Non-experimental versions released: 0x01 0x02 diff --git a/include/openvswitch/compiler.h b/include/openvswitch/compiler.h index 0076ad763578..c7cb9308d029 100644 --- a/include/openvswitch/compiler.h +++ b/include/openvswitch/compiler.h @@ -243,9 +243,13 @@ #ifdef __CHECKER__ #define BUILD_ASSERT(EXPR) ((void) 0) #define BUILD_ASSERT_DECL(EXPR) extern int (*build_assert(void))[1] -#elif defined(__cplusplus) +#elif defined(__cplusplus) && __cplusplus >= 201103L #define BUILD_ASSERT(EXPR) static_assert(EXPR, "assertion failed") #define BUILD_ASSERT_DECL(EXPR) static_assert(EXPR, "assertion failed") +#elif defined(__cplusplus) && __cplusplus < 201103L +#include +#define BUILD_ASSERT BOOST_STATIC_ASSERT +#define BUILD_ASSERT_DECL BOOST_STATIC_ASSERT #elif (__GNUC__ * 256 + __GNUC_MINOR__ >= 0x403 \ || __has_extension(c_static_assert)) #define BUILD_ASSERT_DECL(EXPR) _Static_assert(EXPR, #EXPR)