summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-12-10 12:58:01 -0800
committerVito Caputo <vcaputo@pengaru.com>2022-12-10 13:47:49 -0800
commit31a8f20fab6ba491503f685077c1a6b62de2db34 (patch)
tree03cbd1a7fb871998af9b267dc7ceceaac385f8b8 /src
parent6cdb24ee9446cb0f19e7de8ac6d7db31a889b657 (diff)
macros: introduce some debug printing helpers
Conditional on SARS_DEBUG defined (CFLAGS=-DSARS_DEBUG) This commit only adds the helpers, no actual users yet.
Diffstat (limited to 'src')
-rw-r--r--src/macros.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/macros.h b/src/macros.h
index 091af77..441a93b 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -20,6 +20,19 @@
#include <stdio.h>
#include <stdlib.h>
+#ifdef SARS_DEBUG
+#define debugf(_fmt, ...) \
+ fprintf(stderr, "%s:%d: " _fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#else
+#define debugf(_fmt, ...) \
+ do { } while (0);
+#endif
+
+#define debug_if(_cond, _fmt, ...) \
+ if (_cond) { \
+ debugf(_fmt, ##__VA_ARGS__); \
+ }
+
#define fatal_if(_cond, _fmt, ...) \
if (_cond) { \
fprintf(stderr, "Fatal error: " _fmt "\n", ##__VA_ARGS__); \
© All Rights Reserved