Luna/luna/include/luna/Check.h
apio cda0d49a4e
All checks were successful
continuous-integration/drone/push Build is passing
Add todo()
2022-12-18 17:15:42 +01:00

30 lines
2.0 KiB
C

#pragma once
[[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)
#define unreachable() \
__check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, "Reached unreachable code")
#define todo() __check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, "Reached a TODO!")