summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/debug.h
diff options
context:
space:
mode:
authorPete Hurst <pete@streamuniverse.tv>2013-05-23 02:21:03 +0100
committerPete Hurst <pete@streamuniverse.tv>2013-05-23 02:21:03 +0100
commit3e76512a7c43a8015321f3130f1de259ddf4c83d (patch)
treee4899ac4e1ae1fc573a5728dbec581f1d1961995 /crawl-ref/source/debug.h
parent728a1e39febabb799e09813018265d1ed18a78fe (diff)
downloadcrawl-ref-3e76512a7c43a8015321f3130f1de259ddf4c83d.tar.gz
crawl-ref-3e76512a7c43a8015321f3130f1de259ddf4c83d.zip
Add an ASSERTM macro for more verbose ASSERTs
The syntax is ASSERTM(condition, text, args...) Where text is the format string for an additional message to be printed after the condition and file/line#, and args are additional arguments with which to format the string.
Diffstat (limited to 'crawl-ref/source/debug.h')
-rw-r--r--crawl-ref/source/debug.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/crawl-ref/source/debug.h b/crawl-ref/source/debug.h
index ca4ee23832..7040da6db0 100644
--- a/crawl-ref/source/debug.h
+++ b/crawl-ref/source/debug.h
@@ -52,7 +52,8 @@
#ifdef ASSERTS
-NORETURN void AssertFailed(const char *expr, const char *file, int line);
+NORETURN void AssertFailed(const char *expr, const char *file, int line,
+ const char *text = "", ...);
#ifdef __clang__
# define WARN_PUSH _Pragma("GCC diagnostic push")
@@ -77,9 +78,18 @@ NORETURN void AssertFailed(const char *expr, const char *file, int line);
WARN_POP \
} while (false)
+#define ASSERTM(p,text,...) \
+ do { \
+ WARN_PUSH \
+ IGNORE_ASSERT_WARNINGS \
+ if (!(p)) AssertFailed(#p, __FILE__, __LINE__, text, __VA_ARGS__); \
+ WARN_POP \
+ } while (false)
+
#else
#define ASSERT(p) ((void) 0)
+#define ASSERTM(p,text,...) ((void) 0)
#endif