diff options
Diffstat (limited to 'pjlib/include/pj/assert.h')
-rw-r--r-- | pjlib/include/pj/assert.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pjlib/include/pj/assert.h b/pjlib/include/pj/assert.h index 5a842477..6814e4cd 100644 --- a/pjlib/include/pj/assert.h +++ b/pjlib/include/pj/assert.h @@ -67,6 +67,26 @@ # define PJ_ASSERT_RETURN(expr,retval) pj_assert(expr) #endif +/** + * @hideinitializer + * If #PJ_ENABLE_EXTRA_CHECK is declared and non-zero, then + * #PJ_ASSERT_ON_FAIL macro will evaluate the expression in @a expr during + * run-time. If the expression yields false, assertion will be triggered + * and @a exec_on_fail will be executed. + * + * If #PJ_ENABLE_EXTRA_CHECK is not declared or is zero, then no run-time + * checking will be performed. The macro simply evaluates to pj_assert(expr). + */ +#if defined(PJ_ENABLE_EXTRA_CHECK) && PJ_ENABLE_EXTRA_CHECK != 0 +# define PJ_ASSERT_ON_FAIL(expr,exec_on_fail) \ + do { \ + pj_assert(expr); \ + if (!(expr)) exec_on_fail; \ + } while (0) +#else +# define PJ_ASSERT_ON_FAIL(expr,exec_on_fail) pj_assert(expr) +#endif + /** @} */ #endif /* __PJ_ASSERT_H__ */ |