From 78dca8153f802f271b4f2aeca33d967a075e485e Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 16 Nov 2011 17:01:02 -0500 Subject: Add a dmnsn_unreachable() macro. Also rename inline.h to compiler.h. --- libdimension/dimension/error.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'libdimension/dimension/error.h') diff --git a/libdimension/dimension/error.h b/libdimension/dimension/error.h index ae8ba01..894899a 100644 --- a/libdimension/dimension/error.h +++ b/libdimension/dimension/error.h @@ -39,8 +39,11 @@ * Report an error. * @param[in] str A string to print explaining the error. */ -#define dmnsn_error(str) \ - dmnsn_report_error(true, DMNSN_FUNC, __FILE__, __LINE__, str) +#define dmnsn_error(str) \ + do { \ + dmnsn_report_error(true, DMNSN_FUNC, __FILE__, __LINE__, str); \ + DMNSN_UNREACHABLE(); \ + } while (0) /** * @def dmnsn_assert @@ -54,11 +57,22 @@ #define dmnsn_assert(expr, str) \ do { \ if (!(expr)) { \ - dmnsn_error((str)); \ + dmnsn_error((str)); \ } \ } while (0) #endif +/** + * @def dmnsn_unreachable + * Express that a line of code is unreachable. + * @param[in] str A string to print if the line is reached. + */ +#ifdef NDEBUG + #define dmnsn_unreachable(str) DMNSN_UNREACHABLE() +#else + #define dmnsn_unreachable(str) dmnsn_error((str)) +#endif + /** * @internal * Called by dmnsn_warning() and dmnsn_error(); don't call directly. -- cgit v1.2.3