diff options
Diffstat (limited to 'src/panic.h')
| -rw-r--r-- | src/panic.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/panic.h b/src/panic.h new file mode 100644 index 0000000..fed75d8 --- /dev/null +++ b/src/panic.h @@ -0,0 +1,28 @@ +#ifndef PANIC_H +#define PANIC_H + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <stdbool.h> +#include <SDL3/SDL.h> + +static void panic(const char *why, ...) { + if (!why) return; + va_list ap; + va_start(ap, why); + vfprintf(stderr, why, ap); + fprintf(stderr, "\n"); + va_end(ap); + abort(); +} + +#define must(result) ({ \ + typeof(result) must_result = result; \ + if (!must_result) { \ + panic("SDL: %s", SDL_GetError()); \ + } \ + must_result; \ +}) + +#endif |
