
From: Roland Schwarz
Library authors often use the pattern:
void foo(void) { unsigned res = SomeFuncWithSideEffects(); BOOST_ASSERT(res); }
This causes a lot of noise on some compilers (e.g. gcc) about unused variables when building in release mode.
I suggest a macro
void foo(void) { BOOST_ASSERT_DEF( unsigned res = ) SomeFuncWithSideEffects(); BOOST_ASSERT(res); }
MFC had (has) a VERIFY macro for this. If we introduced a BOOST_VERIFY, the usage would look like: void foo(void) { BOOST_VERIFY( SomeFuncWithSideEffects() ); } Implementation would be (something like): #if defined(NDEBUG) # define BOOST_VERIFY( expression ) expression #else # define BOOST_VERIFY( expression ) bool b = expression; BOOST_ASSERT(b) #endif (Yes, I know; real code would need to invent a unique name that wouldn't clash, or introduce a scope, or something, but you get the idea.) -- Martin Bonner Senior Software Engineer/Team Leader PI SHURLOK LTD Telephone: +44 1223 441434 / 203894 (direct) Fax: +44 1223 203999 Email: martin.bonner@pi-shurlok.com www.pi-shurlok.com disclaimer