diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-02-09 20:51:02 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-02-09 20:51:02 -0500 |
commit | 06b653e922cd36006f0c86b7e015109e5c0b8923 (patch) | |
tree | b45e89ae297e670f7b92c10da30d2ecd46822ac3 /libdimension/dimension/error.h | |
parent | d411e681e571ac054352b9665487f10037d9325d (diff) | |
download | dimension-06b653e922cd36006f0c86b7e015109e5c0b8923.tar.xz |
New dmnsn_assert() macro for invariant violations.
Diffstat (limited to 'libdimension/dimension/error.h')
-rw-r--r-- | libdimension/dimension/error.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libdimension/dimension/error.h b/libdimension/dimension/error.h index 3db61e1..37b8d66 100644 --- a/libdimension/dimension/error.h +++ b/libdimension/dimension/error.h @@ -48,6 +48,16 @@ typedef enum { DMNSN_FUNC, __FILE__, __LINE__, \ str) +/* Make an assertion */ +#ifdef NDEBUG + #define dmnsn_assert(expr, str) ((void)0) +#else + #define dmnsn_assert(expr, str) \ + if (!(expr)) { \ + dmnsn_error(DMNSN_SEVERITY_HIGH, (str)); \ + } +#endif + /* Called by dmnsn_error() - don't call directly */ void dmnsn_report_error(dmnsn_severity severity, const char *func, const char *file, unsigned int line, |