Improved code quality of retro_assert macro

Macros without do{}while() wrapping behave more like regular C expressions. The macro can now be nested/embedded inside of other similar compound statements and conditionals without introducing syntax errors. This change has no risk of negatively impacting existing code.
This commit is contained in:
Jake Stine 2020-11-25 10:16:19 -08:00
parent debb9c6b0a
commit ad12cc089c

View File

@ -27,9 +27,7 @@
#ifdef RARCH_INTERNAL
#include <stdio.h>
#define retro_assert(cond) do { \
if (!(cond)) { printf("Assertion failed at %s:%d.\n", __FILE__, __LINE__); abort(); } \
} while(0)
#define retro_assert(cond) ((void)( (cond) || (printf("Assertion failed at %s:%d.\n", __FILE__, __LINE__), abort(), 0) ))
#else
#define retro_assert(cond) assert(cond)
#endif