I have a problem with the unused local variable warning in GCC.
Often I have code that looks like this:
bool success = foo();
assert(success);
This is fine for debug builds. In release however, the assert compiles to nothing, and GCC gives me a warning.
What is the best way to work around this? Wrapping the bool success = with #ifdef just does not seem like a nice solution…
I would probably define a macro specific to this scenario
I prefer this approach over using a local variable because it doesn’t pollute the method with values that only conditionally exist.
In general I find it very helpful to have 2 sets of macros in my projects