Re: format string warnings for printf vs NSString
Re: format string warnings for printf vs NSString
- Subject: Re: format string warnings for printf vs NSString
- From: Jean-Daniel Dupas <email@hidden>
- Date: Sat, 14 Jan 2012 23:24:30 +0100
Le 14 janv. 2012 à 20:41, Jens Alfke a écrit : 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
For some reason, clang has a special treatment for NSLog and NSLogv, that's why it works with these functions but not for your custom functions.
I'm working on a patch that will solve both issues: - format string is not checked on obj-c methods. - NSString and CFString formats are not checked at all. |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden