diff options
Diffstat (limited to 'src/include/assert.h')
-rw-r--r-- | src/include/assert.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/include/assert.h b/src/include/assert.h index 6d0531801..b3a9b1fe0 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -65,19 +65,22 @@ assert_printf ( const char *fmt, ... ) asm ( "printf" ); #define static_assert(x) _Static_assert( x, #x ) /** - * Assert a condition at link-time. + * Assert a condition at build time (after dead code elimination) * - * If the condition is not true, the link will fail with an unresolved - * symbol (error_symbol). + * If the compiler cannot prove that the condition is true, the build + * will fail with an error message. * * This macro is iPXE-specific. Do not use this macro in code * intended to be portable. - * */ -#define linker_assert( condition, error_symbol ) \ - if ( ! (condition) ) { \ - extern void error_symbol ( void ); \ - error_symbol(); \ - } +#define build_assert( condition ) \ + do { \ + if ( ! (condition) ) { \ + extern void __attribute__ (( error ( \ + "build_assert(" #condition ") failed" \ + ) )) _C2 ( build_assert_, __LINE__ ) ( void ); \ + _C2 ( build_assert_, __LINE__ ) (); \ + } \ + } while ( 0 ) #endif /* _ASSERT_H */ |