On Wed, 17 Jan 2024 08:53:44 +0100
Mattias Rönnblom <hof...@lysator.liu.se> wrote:

> >    * Triggers an error at compilation time if the condition is true.
> >    */
> > -#define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 
> > 2*!!(condition)]))
> > +#define RTE_BUILD_BUG_ON(condition) { static_assert(!(condition), 
> > #condition); }
> >   
> >   /*********** Cache line related macros ********/
> >     
> 
> Should one use RTE_BUILD_BUG_ON() or static_assert() in new DPDK code?
> 
> If static_assert() occasionally needs a work-around, it sounds like 
> keeping using RTE_BUILD_BUG_ON() everywhere is the better choice.

Either choice is the same. Keeping the macro instead of directly using
static_assert will reduce the effort to change when the next C standard
introduces something different.

But using static_assert() can allow for a better warning message.

Reply via email to