c++ - Assert and unused local variable warning in GCC don't mix well? -
i have problem unused local variable warning in gcc.
often have code looks this:
bool success = foo(); assert(success); this fine debug builds. in release however, assert compiles nothing, , gcc gives me warning.
what best way work around this? wrapping bool success = #ifdef not seem nice solution...
i define macro specific scenario
#ifndef ndebug #define verify(expression) assert(expression) #else #define verify(expression) expression #endif i prefer approach on using local variable because doesn't pollute method values conditionally exist.
in general find helpful have 2 sets of macros in projects
- assertxxx: debug execution
- verifyxxx: retail + debug execution
Comments
Post a Comment