Reputation: 3803
I am getting "unused parameter 'testString'" warning from following code. But I am using testString to log. So how come it is unused ?
- (void)getString:(NSString *)testString {
ICELogInfo(@"%@", testString);
}
ICELogInfo is a macro for NSLog.
#define ICELogInfo(fmt, ...) LOG_FORMAT(fmt, @"INFO", ##__VA_ARGS__)
#define LOG_FORMAT(fmt, lvl, ...) LOG_FORMAT_NO_LOCATION(fmt, lvl, ##__VA_ARGS__)
#define LOG_FORMAT_NO_LOCATION(fmt, lvl, ...) NSLog((@"%@ " fmt), lvl, ##__VA_ARGS__)
What I am doing wrong ?
Upvotes: 7
Views: 1791
Reputation: 4772
What version of Xcode are you using? This looks like a lambda capture bug in LLVM from over a year ago now:
as the VA_ARGS in those macros can be expected to work out to the same problem described in that bug report; but it should be resolved in recent Xcodes. Definitely is in Xcode 5 DP 3 that I'm running right now, your code gives me no warnings.
Upvotes: 1
Reputation: 5775
You aren't doing something wrong. This is a common problem when using macros.
As a workaround if you want to get rid of the warning, you can use this code:
- (void)getString:(NSSTring*) __unused testString {
ICELogInfo(@"%@", testString);
}
Upvotes: 6
Reputation: 14251
I've run into the same "problem" before. Solved it by using the unused
flag as e.g.
- (void)getString:(NSString *)testString {
ICELogInfo(@"%@", testString);
#pragma unused (testString)
}
Upvotes: 2