summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-02-09 20:51:02 -0500
committerTavian Barnes <tavianator@gmail.com>2010-02-09 20:51:02 -0500
commit06b653e922cd36006f0c86b7e015109e5c0b8923 (patch)
treeb45e89ae297e670f7b92c10da30d2ecd46822ac3 /libdimension/dimension
parentd411e681e571ac054352b9665487f10037d9325d (diff)
downloaddimension-06b653e922cd36006f0c86b7e015109e5c0b8923.tar.xz
New dmnsn_assert() macro for invariant violations.
Diffstat (limited to 'libdimension/dimension')
-rw-r--r--libdimension/dimension/error.h10
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,