From f555fa01697bde241a4152af4075cf4ba639e96e Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Fri, 19 Jan 2024 16:00:48 +0100 Subject: assert: print location when debugging --- nitro.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nitro.c b/nitro.c index 24d5464..1718832 100644 --- a/nitro.c +++ b/nitro.c @@ -26,8 +26,14 @@ #include #include -// no error message +/* no stdio */ +#ifdef DEBUG +#define assert(x) \ + do { if(!(x)) { prn(2, "%s:%d: %s: error: assertion failed: %s\n", \ + __FILE__, __LINE__, __func__, #x); abort(); } } while(0); +#else #define assert(x) do { if(!(x)) abort(); } while(0); +#endif extern char **environ; char **child_environ; -- cgit 1.4.1