codebased/include/common/panic.h
2023-04-14 02:17:45 +02:00

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