JacksEscape/util/assert.h

22 lines
676 B
C
Raw Normal View History

2024-02-29 16:17:55 +08:00
#pragma once
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
inline static void __panicf(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
int ret = vfprintf(stderr, fmt, args);
va_end(args);
abort();
}
#define ASSERT(expr) \
do { \
if (!(expr)) \
__panicf("Assertion failed: " __FILE__ ":%d[%s]\n Expression: %s", __LINE__, __func__, #expr); \
} while (0)