I got this recommendation from a embedded newsletter:
The assert macro disappears when the debug switch isn't defined. But assert can take any argument, including assignment statements and function calls. It's possible that the code will run differently depending on whether the debug switch is defined or not.
Instead, define and use a slightly different version of assert:
#define assert_e(a) ((void)(a), assert(a))
I have done something like this in my own code:
Code: Select all
#if defined(NASSERT)
#define ASSERT(test) ((void)(test))
#else
#define ASSERT(test) ((test) ? ((void)0) : OnFail(__FILE__,__LINE__))
#endif