diff options
Diffstat (limited to 'util.h')
| -rw-r--r-- | util.h | 24 |
1 files changed, 0 insertions, 24 deletions
| @@ -1,24 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <stdarg.h> | ||
| 4 | #include <stdio.h> | ||
| 5 | #include <stdlib.h> | ||
| 6 | |||
| 7 | static void | ||
| 8 | error(const char *msg, ...) | ||
| 9 | { | ||
| 10 | va_list ap; | ||
| 11 | |||
| 12 | va_start(ap, msg); | ||
| 13 | fprintf(stderr, "Error: "); | ||
| 14 | vfprintf(stderr, msg, ap); | ||
| 15 | va_end(ap); | ||
| 16 | fprintf(stderr, "\n"); | ||
| 17 | exit(EXIT_FAILURE); | ||
| 18 | } | ||
| 19 | |||
| 20 | #define ERROR(msg) error(msg " in \"%s()\" (%s:%d)", __func__, __FILE__, __LINE__) | ||
| 21 | |||
| 22 | #ifndef NELEM | ||
| 23 | # define NELEM(x) (sizeof(x) / sizeof(x[0])) /* NOLINT */ | ||
| 24 | #endif | ||
