On Sat, Nov 11, 2023 at 06:52:26PM +0100, Morten Brørup wrote: > > From: Stephen Hemminger [mailto:step...@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 <step...@networkplumber.org> > > --- > > 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+hyx...@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 <m...@smartsharesystems.com> one more time for good measure, this is an important change. Acked-by: Tyler Retzlaff <roret...@linux.microsoft.com>