• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: format string warnings for printf vs NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

-- Jean-Daniel




 _______________________________________________
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

  • Follow-Ups:
    • Re: format string warnings for printf vs NSString
      • From: Sean McBride <email@hidden>
References: 
 >format string warnings for printf vs NSString (From: Sean McBride <email@hidden>)
 >Re: format string warnings for printf vs NSString (From: Jean-Daniel Dupas <email@hidden>)
 >Re: format string warnings for printf vs NSString (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: framework problem
  • Next by Date: Archiving produces nothing?
  • Previous by thread: Re: format string warnings for printf vs NSString
  • Next by thread: Re: format string warnings for printf vs NSString
  • Index(es):
    • Date
    • Thread