aboutsummaryrefslogtreecommitdiff
path: root/debug.h
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-10-28 01:27:58 +0100
committerubq323 <ubq323@ubq323.website>2022-10-28 01:27:58 +0100
commit612ae13c83235092d100b8ee86c5b7425aa36c36 (patch)
tree904712891db67a502dc7324ad602a11d5a6f9132 /debug.h
parentc524506e04927a39648d47ba55af4fdff32faab6 (diff)
move debug macros to a different header file
Diffstat (limited to 'debug.h')
-rw-r--r--debug.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/debug.h b/debug.h
new file mode 100644
index 0000000..25bb859
--- /dev/null
+++ b/debug.h
@@ -0,0 +1,30 @@
+#ifndef debug_h_INCLUDED
+#define debug_h_INCLUDED
+
+
+#ifdef DEBUG
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define DP(x) puts(x)
+#define DPn(name,x,len) \
+ do { \
+ char *__xxx = strndup(x,len); \
+ printf(name " [%s]\n",__xxx); \
+ free(__xxx); \
+ } while (0)
+#define DPf(...) fprintf(stderr,__VA_ARGS__)
+
+
+#else
+
+#define DP(x)
+#define DPn(n,x,l)
+#define DPf(...)
+
+#endif
+
+#endif // debug_h_INCLUDED
+