[RFC] eal: use _Static_assert() for RTE_BUILD_BUG_ON
Morten Brørup
mb at smartsharesystems.com
Sat Nov 11 18:52:26 CET 2023
> From: Stephen Hemminger [mailto:stephen at 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 <stephen at 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+HYXw27@bricha3-MOBL.ger.corp.intel.com/
Acked-by: Morten Brørup <mb at smartsharesystems.com>
More information about the dev
mailing list