summaryrefslogtreecommitdiff
path: root/src/panic.h
diff options
context:
space:
mode:
authorraven <citrons@mondecitronne.com>2026-04-08 22:51:39 -0500
committerraven <citrons@mondecitronne.com>2026-04-08 22:51:39 -0500
commit18a86e1038b20cb6f8922beead08dcc24ba2a4d3 (patch)
tree85cb74210d67d42763a4709d18af93aa60a8f400 /src/panic.h
parent4a3429a96b5b5ea7468540349aeb4535d5738053 (diff)
rewrite and port to SDL3
Diffstat (limited to 'src/panic.h')
-rw-r--r--src/panic.h28
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