1
0
mirror of synced 2025-01-19 01:24:15 +01:00

impr: Make sure assertion handler doesn't get called too often

This commit is contained in:
WerWolv 2024-06-26 19:10:43 +02:00
parent 5a10613dd2
commit e1a4707569
2 changed files with 7 additions and 9 deletions

View File

@ -144,14 +144,12 @@ namespace hex::log {
fmt::print(dest, "{0}", std::string(projectNameLength > MaxTagLength ? 0 : MaxTagLength - projectNameLength, ' '));
}
void assertionHandler(bool expr, const char* exprString, const char* file, int line) {
if (!expr) [[unlikely]] {
log::error("Assertion failed: {} at {}:{}", exprString, file, line);
void assertionHandler(const char* exprString, const char* file, int line) {
log::error("Assertion failed: {} at {}:{}", exprString, file, line);
#if defined (DEBUG)
std::abort();
#endif
}
#if defined (DEBUG)
std::abort();
#endif
}
namespace color {

View File

@ -21,9 +21,9 @@
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
namespace hex::log::impl {
void assertionHandler(bool expr, const char* expr_str, const char* file, int line);
void assertionHandler(const char* expr_str, const char* file, int line);
}
#define IM_ASSERT(_EXPR) hex::log::impl::assertionHandler(_EXPR, #_EXPR, __FILE__, __LINE__)
#define IM_ASSERT(_EXPR) do { if (!(_EXPR)) [[unlikely]] { hex::log::impl::assertionHandler(#_EXPR, __FILE__, __LINE__); } } while(0)
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
// Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.