diff options
Diffstat (limited to 'woip/c/debug.h')
-rw-r--r-- | woip/c/debug.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/woip/c/debug.h b/woip/c/debug.h new file mode 100644 index 0000000..efc871a --- /dev/null +++ b/woip/c/debug.h @@ -0,0 +1,32 @@ +#ifndef __DEBUG_H__ +#define __DEBUG_H__ + +#include <stdbool.h> +#include <errno.h> +#include <string.h> + +#ifdef STRIP_DEBUG +#define debug(...) +#else +#define debug(fmt, ...) (debug ? fprintf(stderr, "debug: " fmt "\n", \ + ##__VA_ARGS__) : false) +#endif + +#define fatal(error, ...) do { \ + fprintf(stderr, error, ##__VA_ARGS__); \ + fprintf(stderr, " (errno %d: %s)\n", errno, strerror(errno)); \ + exit(1); \ + } while(0) + + +#ifndef __GNUC__ +#error I want GNU C plz +#endif + +#ifdef DEBUG +static bool debug = true; +#else +static bool debug = false; +#endif + +#endif |