-
Notifications
You must be signed in to change notification settings - Fork 9
/
die.h
27 lines (21 loc) · 801 Bytes
/
die.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
#ifndef __DIE_H__
#define __DIE_H__
#include <stdlib.h>
#define die(fmt, ...) do { \
fprintf(stderr, "%s:%d "fmt"\n", __FILE__, __LINE__, ##__VA_ARGS__); \
exit(0); \
} while(0)
#define die_errno(s) do { \
die("%s: %s", (s), strerror(errno)); \
} while(0)
#define die_unless(a) do { \
if (!(a)) { \
die("%s", #a); \
} \
} while (0)
#define die_errno_unless(a) do { \
if (!(a)) { \
die_errno(#a); \
} \
} while (0)
#endif /* __DIE_H__ */