From 7b1520c4d922d64faedb4a056165c5ffd3547eab Mon Sep 17 00:00:00 2001 From: Ray Smith Date: Wed, 1 May 2024 13:33:40 +0100 Subject: [PATCH] helpers: don't override C++11's built-in static_assert The #ifndef doesn't work with the built-in static_assert from C++11, so it ends up getting redefined. It seems that there are other versions of static_assert internally in some C++ standard library implementations that have additional arguments, and these also get overwritten by the two-argument version here. Detect if we're using a suitably-recent version of C++ and avoid the redefintion in that case. Signed-off-by: Ray Smith --- shared/helpers.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shared/helpers.h b/shared/helpers.h index 10a9de0e..7ff60d03 100644 --- a/shared/helpers.h +++ b/shared/helpers.h @@ -181,6 +181,7 @@ do { \ * @param cond Expression to check for truth * @param msg Message to print on failure */ +#if !(defined(__cplusplus) && __cplusplus >= 201103L) #ifndef static_assert # ifdef _Static_assert # define static_assert(cond, msg) _Static_assert(cond, msg) @@ -188,6 +189,7 @@ do { \ # define static_assert(cond, msg) # endif #endif +#endif /** Ensure argument is of given type */ #ifndef TYPEVERIFY