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> --- lib/eal/include/rte_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index c1ba32d00e47..2c63206223b8 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -495,7 +495,7 @@ rte_is_aligned(const void * const __rte_restrict ptr, const unsigned int align) /** * 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(e) _Static_assert(!(e), #e) /*********** Cache line related macros ********/ -- 2.39.2