blob: efc871ac8c4cd8a8ad384bbea898c41cbec48d82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
|