[Feat]: more refined MOBILEGL_ASSERT() macro

This commit is contained in:
2025-11-25 14:12:46 +08:00
parent 7fe156cebc
commit 1a997ae8d4
+9 -1
View File
@@ -43,12 +43,20 @@
#define MOBILEGL_LOG_FILE_PATH ""
#endif
#if _MSC_VER
#define TRAP assert(false)
#elif __clang__
#define TRAP __builtin_debugtrap()
#else
#define TRAP raise(SIGTRAP)
#endif
// =============================== Utils ================================ //
#define MOBILEGL_ASSERT(condition, ...) \
do { \
if (!(condition)) { \
MGLOG_F("Assertion failed" __VA_OPT__(": ") __VA_ARGS__); \
MGLOG_F(" at %s:%d (%s)", __FILE__, __LINE__, __func__); \
assert(false); \
TRAP; \
} \
} while (0)