-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
39 lines (33 loc) · 2 KB
/
util.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
33
34
35
36
37
38
39
#ifndef UTIL_H
#define UTIL_H
#include <stdio.h>
#include <stdlib.h>
#define error(fmt, ...) \
do \
{ \
fprintf (stderr, "%s:%d (%s): ", __FUNCTION__, __LINE__, __FILE__); \
fprintf (stderr, fmt, ##__VA_ARGS__); \
fprintf (stderr, "\n"); \
exit (1); \
} \
while (0)
#define error_if(expr, fmt, ...) \
do \
if (expr) \
error (fmt, ##__VA_ARGS__); \
while (0)
#define printf_return(fmt, ...) \
do \
{ \
printf (fmt, ##__VA_ARGS__); \
return; \
} \
while (0)
#define printf_goto(label, fmt, ...) \
do \
{ \
printf (fmt, ##__VA_ARGS__); \
goto label; \
} \
while (0)
#endif