I get a weird semantic issue:
missing ‘[‘ at start of message send expression
and a parse issue:
Expected ‘]’
in NSLog line of AFURLConnectionOperation.m:
@catch(NSException *e) { caughtException = e; }
if(caughtException) {
NSLog(NSLocalizedString(@"Unhandled exception on %@ networking thread: %@, userInfo: %@", nil), NSStringFromClass([self class]), caughtException, [caughtException userInfo]);
}
[exceptionPool drain];
after I added
#define NSLog(__FORMAT__, ...) TFLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
to my project’s pre-compile file: Proj-Prefix.pch
How can I fix this error?
I searched but without any workaround except comment out the NSLog line..
Thanks in advance!
EDIT:
NSLog(@"%@", [NSString stringWithFormat:NSLocalizedString(@"Unhandled exception on %@ networking thread: %@, userInfo: %@", nil), NSStringFromClass([self class]), caughtException, [caughtException userInfo]]);
and
NSLog(@"Unhandled exception on %@ networking thread: %@, userInfo: %@", NSStringFromClass([self class]), caughtException, [caughtException userInfo]);
are okay.
But why the original one does not? 😕
Think about the macro expansion. In your macro, you’re trying to use string literal concatenation:
But the value of the
__FORMAT__parameter isNSLocalizedString(@"Unhandled exception on %@ networking thread: %@, userInfo: %@", nil), which is not a string literal. The expansion looks like this:Clearly that’s erroneous syntax. The error is made extra-inscrutable because
NSLocalizedStringis itself a macro (defined inNSBundle.h), so the full expansion looks like this:By the way, you should not use
__FORMAT__as your macro parameter name. All identifiers that begin with two underscores are reserved. (Also reserved are all identifiers that begin with an underscore followed by a capital letter.)