On Jan 13, 2012, at 3:36 PM, Jean-Daniel Dupas wrote: It works on function call (NSLog) but not on methods. It look like it was never implemented in clang, so it may be worth filling a bug report about it.
In my projects* it works with NSLog, but not on my own C functions that I give the identical attribute to, strangely enough:
FOUNDATION_EXPORT void OtherLog(NSString* format, ...) NS_FORMAT_FUNCTION(1,2); static void test(void) { OtherLog(@"too many params: %@“); // no error here! NSLog(@"too many params: %@“); // error here }
The compiler correctly flags the NSLog call as an error, but not the OtherLog call … even though the declaration of NSLog in NSObjCRuntime.h is pretty much identical to my declaration of OtherLog: FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2);
What’s going on here? Please tell me Clang isn’t hardcoded to recognize NSLog... :-p
—Jens
* OS X 10.7.2, Xcode 4.2.1, 10.7 SDK, Apple LLVM Compiler 3.0, -Wformat-security and -Wall enabled
|