Suppress MSVC CRT assert dialogs. (#395)

This commit is contained in:
Branimir Karadžić
2026-05-13 21:19:21 -07:00
committed by GitHub
parent 217823bc0a
commit eed706fb27
3 changed files with 138 additions and 12 deletions

View File

@@ -79,7 +79,7 @@ int runAllTests(int32_t _argc, const char* _argv[])
ConfigData config;
config.defaultColourMode = BX_PLATFORM_EMSCRIPTEN
? ColourMode::None
: ColourMode::PlatformDefault
: ColourMode::PlatformDefault
;
config.showDurations = ShowDurations::Always;

View File

@@ -11,20 +11,26 @@
// Override bx asserts in test builds: failing asserts throw std::exception so that Catch2's
// REQUIRE_ASSERTS (REQUIRE_THROWS) can catch them.
#if BX_CONFIG_DEBUG
# define BX_ASSERT(_condition, ...) \
do { \
if (!(_condition) ) \
{ \
throw ::std::exception(); \
} \
# define BX_ASSERT(_condition, ...) \
do { \
if (!(_condition) ) \
{ \
BX_PRAGMA_DIAGNOSTIC_PUSH(); \
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4297); \
throw ::std::exception(); \
BX_PRAGMA_DIAGNOSTIC_POP(); \
} \
} while (false)
# define BX_ASSERT_LOC(_location, _condition, ...) \
do { \
(void)(_location); \
if (!(_condition) ) \
{ \
throw ::std::exception(); \
do { \
(void)(_location); \
if (!(_condition) ) \
{ \
BX_PRAGMA_DIAGNOSTIC_PUSH(); \
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4297); \
throw ::std::exception(); \
BX_PRAGMA_DIAGNOSTIC_POP(); \
} \
} while (false)
#endif // BX_CONFIG_DEBUG