I don't see where this would cause any harm, except for a system that is compiled with this code by somebody who makes a mistake in the assert code and then compiles it on a system that does not do this.Solar wrote: One notion on Candy's post:
The assert() macro you get by including [tt]<assert.h>[/tt] does not execute the assertion when NDEBUG is defined. Which means, Candy's code fragment
is nice, but non-standard. (Standard would be [tt]#define assert(x) ( (void) 0 )[/tt].) If you do non-standard things, consider naming the function / macro in a non-standard way. While persons used to the standard assert() wouldn't put side-effects in there anyway, it's better to play it safe IMHO.Code: Select all
#else #define assert(x) x
For all purposes it is an assert, with the side note that it does not cause side-effects and it is slightly slower on non-properly-optimizing compilers when building a release without debug code (but then again, if you're going to compile a release, use an optimizing compiler). I honestly don't see where this would cause a problem (except for training new people to comply with the original type of assert - but I don't see the point of that, if you can just use this one instead).