forked from sysprog21/phonebook-concurrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.h
32 lines (30 loc) · 724 Bytes
/
debug.h
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
/**
* @file This file is for Debug, we can use this file like logcat
*/
/**
* error detect for unix command
*/
#define syserr(variable, function) \
if (variable) { \
perror(function); \
exit(EXIT_FAILURE); \
}
/**
* Define own log and debug output.
*
* "__VA_ARG__" is varible MACRO substitue. It can make MACRO printf
* include formats and arguments.
*/
#ifdef DEBUG
#define dprintf(...) printf("DEBUG: " __VA_ARGS__)
#define eprintf(...) \
do { \
fprintf(stderr, "ERROR: "); fprintf(stderr, __VA_ARGS__); \
} while (0)
#else
#define dprintf(...)
#define eprintf(...) \
do { \
fprintf(stderr, "ERROR: "); fprintf(stderr, __VA_ARGS__); \
} while (0)
#endif