Luna/luna/include/luna/Check.h
apio 8598b1e8fc
All checks were successful
continuous-integration/drone/push Build is passing
Replace the _noreturn macro with the C++ native attribute [[noreturn]]
2022-12-06 19:40:35 +01:00

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)