Is it OK to set debugging macros to empty string when I want to disable debug checks?
Both assert and BOOST_ASSERT are set to ((void)0) when NDEBUG is defined.
Why not to do something line this?
#ifdef NDEBUG
#define MY_DEBUG_MACRO_FUNCTION(x,y,z) ""
#elif
// define macros
#endif
The idea is for the macro to do nothing on release builds. You could define it to an empty string literal, since
"";is a valid expression. I would believe the reason of being defined to((void)0)is so that the implementation does not emmit warnings for the expression. I have no solid grounds to say this, but some minimal testing shows that"";generates a warning while((void)0)doesn’t. Of course, warnings are not standarized so there could be a particular implementation that does emit a warning for((void)0)as well, but it would have to defineassertto something else that doesn’t onNDEBUGbuilds or it would be quite annoying to the user.