26 lines
1.7 KiB
C
26 lines
1.7 KiB
C
#pragma once
|
|
#include <luna/Attributes.h>
|
|
|
|
[[noreturn]] extern bool __check_failed(const char* file, const char* line, const char* func, const char* expr);
|
|
|
|
#ifndef STRINGIZE_VALUE_OF
|
|
#define STRINGIZE(x) #x
|
|
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
|
|
#endif
|
|
|
|
#define expect(expr, message) \
|
|
do { \
|
|
if (!(expr)) [[unlikely]] \
|
|
{ \
|
|
__check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, message); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define check(expr) \
|
|
do { \
|
|
if (!(expr)) [[unlikely]] \
|
|
{ \
|
|
__check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, #expr); \
|
|
} \
|
|
} while (0)
|