• 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: Jens Alfke <email@hidden>
  • Date: Sat, 14 Jan 2012 11:41:12 -0800


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

 _______________________________________________
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: Jean-Daniel Dupas <email@hidden>
    • Re: format string warnings for printf vs NSString
      • From: Jens Alfke <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>)

  • Prev by Date: framework problem
  • Next by Date: Re: framework problem
  • 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