Submodule subprojects/c-stdaux 1bcec74..11930d2: diff --git a/subprojects/c-stdaux/src/c-stdaux.h b/subprojects/c-stdaux/src/c-stdaux.h index d305780..a02aed9 100644 --- a/subprojects/c-stdaux/src/c-stdaux.h +++ b/subprojects/c-stdaux/src/c-stdaux.h @@ -437,9 +437,10 @@ _Static_assert(_assertion, _message); \ * macro is used with constant expressions, the compiler will be able to * optimize it away. */ -static inline void c_assert(bool expr_result) { - assert(expr_result); -} +#define c_assert(_x) ({ \ + const _c_unused_ bool c_assert_result = (_x); \ + assert(c_assert_result && #_x); \ + }) /** * c_errno() - return valid errno diff --git a/subprojects/c-stdaux/src/test-api.c b/subprojects/c-stdaux/src/test-api.c index 31d4d54..fb50066 100644 --- a/subprojects/c-stdaux/src/test-api.c +++ b/subprojects/c-stdaux/src/test-api.c @@ -170,6 +170,11 @@ static void test_api_macros(void) { c_assert(c_align_to(0, 0) == 0); } + /* c_assert */ + { + c_assert(true); + } + /* C_DEFINE_CLEANUP / C_DEFINE_DIRECT_CLEANUP */ { int v = 0; @@ -181,7 +186,6 @@ static void test_api_macros(void) { static void test_api_functions(void) { void *fns[] = { - (void *)c_assert, (void *)c_errno, (void *)c_free, (void *)c_close,