20 lines
545 B
C
20 lines
545 B
C
#ifndef _ASSERT_H
|
|
#define _ASSERT_H
|
|
|
|
void __assert_fail(const char *expr, const char *file, unsigned int line,
|
|
const char *func) __attribute__((noreturn));
|
|
|
|
#ifdef NDEBUG
|
|
# define assert(x) ((void)0)
|
|
#else
|
|
# define assert(x) ((x) ? (void)0 : \
|
|
__assert_fail(#x, __FILE__, __LINE__, __func__))
|
|
#endif
|
|
|
|
// C11 static_assert — clang implements `_Static_assert` as a keyword.
|
|
// The macro spelling allows portable code that uses `static_assert(...)`.
|
|
#ifndef __cplusplus
|
|
# define static_assert _Static_assert
|
|
#endif
|
|
|
|
#endif
|