diff options
-rw-r--r-- | src/macros.h | 13 |
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__); \ |