aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-01-26 20:13:39 +0100
committerAnton Khirnov <anton@khirnov.net>2020-01-26 20:14:34 +0100
commit5c58342886ffbf56544e5ae9e8dd3ac1d6e2c39f (patch)
treed4125b23d7d44b317d5cd1d5c6f6197857817255
parent246c2746a25121ad51360f2ebb6c4b8073ea10e4 (diff)
common: print the source location in mg2di_assert()
-rw-r--r--common.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/common.h b/common.h
index 0c644bd..9c36a33 100644
--- a/common.h
+++ b/common.h
@@ -30,12 +30,16 @@
#define FD_STENCIL_MAX 4
-#define mg2di_assert(x) \
-do { \
- if (!(x)) { \
- fputs("Assertion " #x " failed\n", stderr); \
- abort(); \
- } \
+#define STRINGIFY(x) #x
+#define SOURCE_LOC(f, l) f ":" STRINGIFY(l)
+
+#define mg2di_assert(x) \
+do { \
+ if (!(x)) { \
+ fputs(SOURCE_LOC(__FILE__, __LINE__) \
+ ": " "Assertion " #x " failed\n", stderr); \
+ abort(); \
+ } \
} while (0)
#endif /* MG2D_COMMON_H */