25 lines
1.1 KiB
C
25 lines
1.1 KiB
C
#ifndef COMMON_PANIC_H
|
|
#define COMMON_PANIC_H
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define PANIC(...) \
|
|
(fputs("panic: ", stderr), \
|
|
fprintf(stderr, __VA_ARGS__), \
|
|
fprintf( \
|
|
stderr, "\n\tat ./%s:%d in %s()\n", __FILE__, __LINE__, __func__ \
|
|
), \
|
|
exit(1))
|
|
|
|
#define ASSERT(condition, ...) \
|
|
if (!(condition)) \
|
|
(fputs("assertion failed: ", stderr), \
|
|
fprintf(stderr, __VA_ARGS__), \
|
|
fprintf( \
|
|
stderr, "\n\tat ./%s:%d in %s()\n", __FILE__, __LINE__, __func__ \
|
|
), \
|
|
exit(1))
|
|
|
|
#endif
|