diff --git a/include/ucore/utils.h b/include/ucore/utils.h index 1b3737e..c6f08c1 100644 --- a/include/ucore/utils.h +++ b/include/ucore/utils.h @@ -4,7 +4,7 @@ //Gnerate a compiler error if the compile time //constant expression fails -#define STATIC_ASSERT(expr) \ +#define UC_STATIC_ASSERT(expr) \ do { \ enum { assert_static__ = 1/(expr) }; \ } while (0) @@ -58,5 +58,17 @@ typeof( ((type *)0)->member ) *__mptr = (ptr); \ #define UC_STRINGIFY(x) UC_STRINGIFY_HLP(x) #define UC_STRINGIFY_HLP(x) #x + +/** + * assert() that is not affected by NDEBUG define + */ +#define UC_ASSERT(expr) do {\ +if (!(expr) ) {\ + fprintf(stderr,\ + "UC_ASSERT failed '%s' %s:%d\n", UC_STRINGIFY(expr), __FILE__, __LINE__);\ + uc_backtrace_fd(3);\ + abort();\ +} while (0) + #endif