Derive-C
Loading...
Searching...
No Matches
panic.h
Go to the documentation of this file.
1#ifndef PANIC
2
3#include <assert.h>
4#include <stdio.h>
5#include <stdlib.h>
6
7#define PANIC(...) \
8 do { \
9 fprintf(stderr, __VA_ARGS__); \
10 abort(); \
11 } while (0);
12#endif
13
14#ifndef ASSERT
15#define ASSERT(expr, ...) \
16 if (!(expr)) { \
17 PANIC("assertion " #expr " failed: " __VA_ARGS__ "\n"); \
18 }
19#endif
20
21#ifdef NDEBUG
22#define DEBUG_ASSERT(expr) ASSERT(expr)
23#else
24#define DEBUG_ASSERT(expr)
25#endif