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 <rsmith@brightsign.biz>
This commit is contained in:
Ray Smith 2024-05-01 13:33:40 +01:00 committed by Marius Vlad
parent 302a1b143f
commit 7b1520c4d9
1 changed files with 2 additions and 0 deletions

View File

@ -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