about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2024-01-19 16:00:48 +0100
committerLeah Neukirchen <leah@vuxu.org>2024-01-19 16:00:48 +0100
commitf555fa01697bde241a4152af4075cf4ba639e96e (patch)
tree2af8e4c015c6551a0afb401c3892a825deb6e7e3
parent186bf1f894242c91e1877d3bfe11ae0623200450 (diff)
downloadnitro-f555fa01697bde241a4152af4075cf4ba639e96e.tar.gz
nitro-f555fa01697bde241a4152af4075cf4ba639e96e.tar.xz
nitro-f555fa01697bde241a4152af4075cf4ba639e96e.zip
assert: print location when debugging
-rw-r--r--nitro.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/nitro.c b/nitro.c
index 24d5464..1718832 100644
--- a/nitro.c
+++ b/nitro.c
@@ -26,8 +26,14 @@
 #include <termios.h>
 #include <unistd.h>
 
-// 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;