From 5c58342886ffbf56544e5ae9e8dd3ac1d6e2c39f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 26 Jan 2020 20:13:39 +0100 Subject: common: print the source location in mg2di_assert() --- common.h | 16 ++++++++++------ 1 file 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 */ -- cgit v1.2.3