mirror of
https://github.com/pound-emu/ballistic.git
synced 2026-06-17 04:16:48 -07:00
e3a0870b86
Added `extern "C"` to every header file to support using Ballistic with C++ projects Signed-off-by: Ronald Caesar <github43132@proton.me>
50 lines
2.4 KiB
C
50 lines
2.4 KiB
C
#ifndef BALLISTIC_COMMON_ASSERT_H
|
|
#define BALLISTIC_COMMON_ASSERT_H
|
|
|
|
#include <stddef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif /* __cplusplus */
|
|
|
|
void bal_internal_assert_fail(const char *file,
|
|
int line,
|
|
const char *func,
|
|
const char *expr_str,
|
|
const char *user_msg,
|
|
...);
|
|
|
|
#define BAL_ASSERT(expression) \
|
|
do \
|
|
{ \
|
|
if (!(expression)) \
|
|
{ \
|
|
bal_internal_assert_fail(__FILE__, __LINE__, __func__, #expression, NULL, NULL); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define BAL_ASSERT_MSG(expression, format, ...) \
|
|
do \
|
|
{ \
|
|
if (!(expression)) \
|
|
{ \
|
|
bal_internal_assert_fail( \
|
|
__FILE__, __LINE__, __func__, #expression, format __VA_OPT__(, ) __VA_ARGS__); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define BAL_UNREACHABLE(...) \
|
|
bal_internal_assert_fail(__FILE__, \
|
|
__LINE__, \
|
|
__func__, \
|
|
"BAL_UNREACHABLE()", \
|
|
"Unreachable code executed", \
|
|
##__VA_ARGS__);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif /* __cplusplus */
|
|
|
|
#endif // BALLISTIC_COMMON_ASSERT_H
|