From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BBD744331C; Mon, 13 Nov 2023 17:30:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE273402CF; Mon, 13 Nov 2023 17:30:19 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 756464026C for ; Mon, 13 Nov 2023 17:30:18 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id CE0F820B74C1; Mon, 13 Nov 2023 08:30:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CE0F820B74C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1699893017; bh=wsS31rDJu385MU8JbFK896AjLQkb6Rl5jMY9iDYGVpU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kgrXpQb9g06fyAsrDIQ3ed32nEypbu1FvgRky8zhfN2yNVcNUqPb/IrVXqT2VjIiB mCU/nqNvgFw8df4yzxyvhJakZricYTVvEnOZMBzm4kW8C8D1KWOmjb0Otp7JKKBwQv 0XFRYMCKk2D4FaxxT4zNn14FHKfInAg9meNnxsdM= Date: Mon, 13 Nov 2023 08:30:17 -0800 From: Tyler Retzlaff To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: Stephen Hemminger , dev@dpdk.org Subject: Re: [RFC] eal: use _Static_assert() for RTE_BUILD_BUG_ON Message-ID: <20231113163017.GC13153@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <20231111172153.57461-1-stephen@networkplumber.org> <98CBD80474FA8B44BF855DF32C47DC35E9F015@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F015@smartserver.smartshare.dk> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Sat, Nov 11, 2023 at 06:52:26PM +0100, Morten Brørup wrote: > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > Sent: Saturday, 11 November 2023 18.22 > > > > The method of doing sizeof a bad array element was an interesting > > hack but it has a couple of problems. First, it won't work if > > VLA checking is enabled. It doesn't enforce that the expression > > is constant. > > > > Replace that with the _Static_assert builtin available in > > Gcc, Clang, and MSVC. > > > > Signed-off-by: Stephen Hemminger > > --- > > Two souls, one thought... > I have been considering exactly the same, and thus strongly support this. > > > -#define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - > > 2*!!(condition)])) > > +#define RTE_BUILD_BUG_ON(e) _Static_assert(!(e), #e) > > Please use static_assert instead of _Static_assert, as discussed with Bruce: > > http://inbox.dpdk.org/dev/ZR%2FlDC88s+HYXw27@bricha3-MOBL.ger.corp.intel.com/ +1 At least in public headers use the macro static_assert for portability with C++. > > Acked-by: Morten Brørup one more time for good measure, this is an important change. Acked-by: Tyler Retzlaff