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:
parent
debb9c6b0a
commit
ad12cc089c
|
@ -27,9 +27,7 @@
|
||||||
|
|
||||||
#ifdef RARCH_INTERNAL
|
#ifdef RARCH_INTERNAL
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define retro_assert(cond) do { \
|
#define retro_assert(cond) ((void)( (cond) || (printf("Assertion failed at %s:%d.\n", __FILE__, __LINE__), abort(), 0) ))
|
||||||
if (!(cond)) { printf("Assertion failed at %s:%d.\n", __FILE__, __LINE__); abort(); } \
|
|
||||||
} while(0)
|
|
||||||
#else
|
#else
|
||||||
#define retro_assert(cond) assert(cond)
|
#define retro_assert(cond) assert(cond)
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue