3#include "PixelBullet/Application/Log.hpp"
17#define DEBUG_BREAK() __debugbreak()
18#elif defined(__linux__)
20#define DEBUG_BREAK() raise(SIGTRAP)
22#define DEBUG_BREAK() std::abort()
37 inline void Fail(
const char* file,
int line,
const char* conditionStr)
39 Log::Error(
"Assertion '{}' failed at {}:{}", conditionStr, file, line);
57 template <
typename... Args>
58 void Fail(
const char* file,
int line,
const char* conditionStr, fmt::format_string<Args...> msg, Args&&... args)
60 Log::Error(msg, std::forward<Args>(args)...);
74 inline void Panic(
const char* file,
int line)
76 Log::Error(
"Panic triggered at {}:{}", file, line);
92 template <
typename... Args>
93 void Panic(
const char* file,
int line, fmt::format_string<Args...> msg, Args&&... args)
95 Log::Error(msg, std::forward<Args>(args)...);
111 Log::Error(
"Reached unreachable code at {}:{}", file, line);
128 template <
typename... Args>
129 void Unreachable(
const char* file,
int line, fmt::format_string<Args...> msg, Args&&... args)
131 Log::Error(msg, std::forward<Args>(args)...);
151#define ASSERT(condition, ...) \
156 PixelBullet::Fail(__FILE__, __LINE__, #condition, ##__VA_ARGS__); \
169#define DEBUG_ASSERT(condition, ...) ASSERT(condition, ##__VA_ARGS__)
171#define DEBUG_ASSERT(condition, ...) ((void)0)
184#define ASSUME(condition, ...) ASSERT(condition, ##__VA_ARGS__)
187#define ASSUME(condition, ...) __assume(condition)
188#elif defined(__clang__) || defined(__GNUC__)
189#define ASSUME(condition, ...) \
193 __builtin_unreachable(); \
196#define ASSUME(condition, ...) ((void)0)
214 PixelBullet::Panic(__FILE__, __LINE__, ##__VA_ARGS__); \
226#define UNREACHABLE(...) \
229 PixelBullet::Unreachable(__FILE__, __LINE__, ##__VA_ARGS__); \
233#define UNREACHABLE(...) __assume(0)
234#elif defined(__clang__) || defined(__GNUC__)
235#define UNREACHABLE(...) __builtin_unreachable()
237#define UNREACHABLE(...) ((void)0)
void Panic(const char *file, int line)
Triggers a panic without a custom message.
Definition Assert.hpp:74
#define DEBUG_BREAK()
Platform-specific debug break.
Definition Assert.hpp:22
void Fail(const char *file, int line, const char *conditionStr)
Fails an assertion without a custom message.
Definition Assert.hpp:37
void Unreachable(const char *file, int line)
Handles unreachable code without a custom message.
Definition Assert.hpp:109