mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 13:48:30 +09:00
[Feat]: more refined MOBILEGL_ASSERT() macro
This commit is contained in:
+9
-1
@@ -43,12 +43,20 @@
|
|||||||
#define MOBILEGL_LOG_FILE_PATH ""
|
#define MOBILEGL_LOG_FILE_PATH ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if _MSC_VER
|
||||||
|
#define TRAP assert(false)
|
||||||
|
#elif __clang__
|
||||||
|
#define TRAP __builtin_debugtrap()
|
||||||
|
#else
|
||||||
|
#define TRAP raise(SIGTRAP)
|
||||||
|
#endif
|
||||||
|
|
||||||
// =============================== Utils ================================ //
|
// =============================== Utils ================================ //
|
||||||
#define MOBILEGL_ASSERT(condition, ...) \
|
#define MOBILEGL_ASSERT(condition, ...) \
|
||||||
do { \
|
do { \
|
||||||
if (!(condition)) { \
|
if (!(condition)) { \
|
||||||
MGLOG_F("Assertion failed" __VA_OPT__(": ") __VA_ARGS__); \
|
MGLOG_F("Assertion failed" __VA_OPT__(": ") __VA_ARGS__); \
|
||||||
MGLOG_F(" at %s:%d (%s)", __FILE__, __LINE__, __func__); \
|
MGLOG_F(" at %s:%d (%s)", __FILE__, __LINE__, __func__); \
|
||||||
assert(false); \
|
TRAP; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|||||||
Reference in New Issue
Block a user