I'd like to code in some preprocessor macros to optionally log some information. For example in the .h
//#define ML_DEBUG(x) (x) // flip this bit to do the error logging
#define ML_DEBUG(x) (1==1) // flip this bit to silence
in the .m I implement like:
ML_DEBUG(NSLog(@"Class dealloc: %@", [NSString stringWithCString:object_getClassName(self)]));
The code works fine as I have presented it. However I don't think my "do nothing" case is as light weight as it could be. I had expected to write:
//#define ML_DEBUG(x) (x) // flip this bit to do the error logging
#define ML_DEBUG(x) (;) // flip this bit to silence
Since a lone semicolon is a valid objective-c statement, I expected this would work, but the compiler is telling me:
expected expression before ';' token
My question is: did I choose the most lightweight "do nothing" statement, by using 1==1 or is there a less intensive way to do this. Or maybe my entire approach to temporary debug logging is wrong-headed?