I'm reviewing a third party codebase and see this definition of an assert
macro:
#define assert( x ) \
if( !( x ) ) { \
ThrowException( __FILE__, __LINE__ ); \
} else \
((void)1)
What's the point in (void)1
? How is it better than idiomatic (void)0
?
There's no difference between (void)1
and (void)0
.
I think it does not matter that much (and will be optimized away by the compiler). And <cassert>
is a standard C++ header (using the standard <assert.h>
C header) which defines a standard assert
macro, so an application should not re-define it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With