@ -847,47 +847,50 @@ extern void ExceptionalCondition(const char *conditionName,
* If the " condition " ( a compile - time - constant expression ) evaluates to false ,
* If the " condition " ( a compile - time - constant expression ) evaluates to false ,
* throw a compile error using the " errmessage " ( a string literal ) .
* throw a compile error using the " errmessage " ( a string literal ) .
*
*
* gcc 4.6 and up supports _Static_assert ( ) , but there are bizarre syntactic
* C11 has _Static_assert ( ) , and most C99 compilers already support that . For
* placement restrictions . Macros StaticAssertStmt ( ) and StaticAssertExpr ( )
* portability , we wrap it into StaticAssertDecl ( ) . _Static_assert ( ) is a
* " declaration " , and so it must be placed where for example a variable
* declaration would be valid . As long as we compile with
* - Wno - declaration - after - statement , that also means it cannot be placed after
* statements in a function . Macros StaticAssertStmt ( ) and StaticAssertExpr ( )
* make it safe to use as a statement or in an expression , respectively .
* make it safe to use as a statement or in an expression , respectively .
* The macro StaticAssertDecl ( ) is suitable for use at file scope ( outside of
* any function ) .
*
*
* Otherwise we fall back on a kluge that assumes the compiler will complain
* For compilers without _Static_assert ( ) , we fall back on a kluge that
* about a negative width for a struct bit - field . This will not include a
* assumes the compiler will complain about a negative width for a struct
* helpful error message , but it beats not getting an error at all .
* bit - field . This will not include a helpful error message , but it beats not
* getting an error at all .
*/
*/
# ifndef __cplusplus
# ifndef __cplusplus
# ifdef HAVE__STATIC_ASSERT
# ifdef HAVE__STATIC_ASSERT
# define StaticAssertDecl(condition, errmessage) \
_Static_assert ( condition , errmessage )
# define StaticAssertStmt(condition, errmessage) \
# define StaticAssertStmt(condition, errmessage) \
do { _Static_assert ( condition , errmessage ) ; } while ( 0 )
do { _Static_assert ( condition , errmessage ) ; } while ( 0 )
# define StaticAssertExpr(condition, errmessage) \
# define StaticAssertExpr(condition, errmessage) \
( ( void ) ( { StaticAssertStmt ( condition , errmessage ) ; true ; } ) )
( ( void ) ( { StaticAssertStmt ( condition , errmessage ) ; true ; } ) )
# define StaticAssertDecl(condition, errmessage) \
_Static_assert ( condition , errmessage )
# else /* !HAVE__STATIC_ASSERT */
# else /* !HAVE__STATIC_ASSERT */
# define StaticAssertDecl(condition, errmessage) \
extern void static_assert_func ( int static_assert_failure [ ( condition ) ? 1 : - 1 ] )
# define StaticAssertStmt(condition, errmessage) \
# define StaticAssertStmt(condition, errmessage) \
( ( void ) sizeof ( struct { int static_assert_failure : ( condition ) ? 1 : - 1 ; } ) )
( ( void ) sizeof ( struct { int static_assert_failure : ( condition ) ? 1 : - 1 ; } ) )
# define StaticAssertExpr(condition, errmessage) \
# define StaticAssertExpr(condition, errmessage) \
StaticAssertStmt ( condition , errmessage )
StaticAssertStmt ( condition , errmessage )
# define StaticAssertDecl(condition, errmessage) \
extern void static_assert_func ( int static_assert_failure [ ( condition ) ? 1 : - 1 ] )
# endif /* HAVE__STATIC_ASSERT */
# endif /* HAVE__STATIC_ASSERT */
# else /* C++ */
# else /* C++ */
# if defined(__cpp_static_assert) && __cpp_static_assert >= 200410
# if defined(__cpp_static_assert) && __cpp_static_assert >= 200410
# define StaticAssertDecl(condition, errmessage) \
static_assert ( condition , errmessage )
# define StaticAssertStmt(condition, errmessage) \
# define StaticAssertStmt(condition, errmessage) \
static_assert ( condition , errmessage )
static_assert ( condition , errmessage )
# define StaticAssertExpr(condition, errmessage) \
# define StaticAssertExpr(condition, errmessage) \
( { static_assert ( condition , errmessage ) ; } )
( { static_assert ( condition , errmessage ) ; } )
# define StaticAssertDecl(condition, errmessage) \
static_assert ( condition , errmessage )
# else /* !__cpp_static_assert */
# else /* !__cpp_static_assert */
# define StaticAssertDecl(condition, errmessage) \
extern void static_assert_func ( int static_assert_failure [ ( condition ) ? 1 : - 1 ] )
# define StaticAssertStmt(condition, errmessage) \
# define StaticAssertStmt(condition, errmessage) \
do { struct static_assert_struct { int static_assert_failure : ( condition ) ? 1 : - 1 ; } ; } while ( 0 )
do { struct static_assert_struct { int static_assert_failure : ( condition ) ? 1 : - 1 ; } ; } while ( 0 )
# define StaticAssertExpr(condition, errmessage) \
# define StaticAssertExpr(condition, errmessage) \
( ( void ) ( { StaticAssertStmt ( condition , errmessage ) ; } ) )
( ( void ) ( { StaticAssertStmt ( condition , errmessage ) ; } ) )
# define StaticAssertDecl(condition, errmessage) \
extern void static_assert_func ( int static_assert_failure [ ( condition ) ? 1 : - 1 ] )
# endif /* __cpp_static_assert */
# endif /* __cpp_static_assert */
# endif /* C++ */
# endif /* C++ */