This commit is contained in:
Your Name
2025-04-28 22:03:12 +12:00
parent 320fd1f3f0
commit ff43e4122a
3 changed files with 10 additions and 32 deletions

View File

@@ -39,39 +39,16 @@ struct SourceLocation {
} // namespace ds
// Define assertion macros with different behaviors based on build configuration
#if defined(NDEBUG) && !defined(DS_ENABLE_RELEASE_ASSERTS)
// Assertions disabled in release builds by default
#define ASSERT(condition) ((void)0)
#define ASSERT_MSG(condition, message) ((void)0)
#else
// Standard assertion
#define ASSERT(condition) \
do { \
if (!(condition)) { \
ds::assert_fail(#condition, DS_CURRENT_LOCATION); \
} \
} while (false)
// Assertion with custom message
#define ASSERT_MSG(condition, message) \
do { \
if (!(condition)) { \
ds::assert_fail(#condition, DS_CURRENT_LOCATION, message); \
} \
} while (false)
#endif
// Always-active assertion for critical checks, even in release builds
#define ASSERT_ALWAYS(condition) \
// Standard assertion
#define ASSERT(condition) \
do { \
if (!(condition)) { \
ds::assert_fail(#condition, DS_CURRENT_LOCATION); \
} \
} while (false)
// Always-active assertion with custom message for critical checks
#define ASSERT_ALWAYS_MSG(condition, message) \
// Assertion with custom message
#define ASSERT_MSG(condition, message) \
do { \
if (!(condition)) { \
ds::assert_fail(#condition, DS_CURRENT_LOCATION, message); \