From 06b653e922cd36006f0c86b7e015109e5c0b8923 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 9 Feb 2010 20:51:02 -0500 Subject: New dmnsn_assert() macro for invariant violations. --- libdimension/dimension/error.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libdimension/dimension') 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, -- cgit v1.2.3