nsxivbbe7ae0
WARN and FATAL macros
+18 −0
1 file changed
- M sxiv.h +18 −0
| @@ -23,4 +23,22 @@ | |||
| 23 | 23 | ||
| 24 | 24 | #define VERSION "git-20110117" | |
| 25 | 25 | ||
| 26 | + | #define WARN(...) \ | |
| 27 | + | do { \ | |
| 28 | + | fprintf(stderr, "sxiv: %s:%d: warning: ", __FILE__, __LINE__); \ | |
| 29 | + | fprintf(stderr, __VA_ARGS__); \ | |
| 30 | + | fprintf(stderr, "\n"); \ | |
| 31 | + | } while (0) | |
| 32 | + | ||
| 33 | + | #define FATAL(...) \ | |
| 34 | + | do { \ | |
| 35 | + | fprintf(stderr, "sxiv: %s:%d: error: ", __FILE__, __LINE__); \ | |
| 36 | + | fprintf(stderr, __VA_ARGS__); \ | |
| 37 | + | fprintf(stderr, "\n"); \ | |
| 38 | + | cleanup(); \ | |
| 39 | + | exit(1); \ | |
| 40 | + | } while (0) | |
| 41 | + | ||
| 42 | + | void cleanup(); | |
| 43 | + | ||
| 26 | 44 | #endif /* SXIV_H */ | |