• 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 not a string literal and no format arguments"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Format not a string literal and no format arguments"


  • Subject: Re: "Format not a string literal and no format arguments"
  • From: Ken Thomases <email@hidden>
  • Date: Tue, 1 Sep 2009 03:18:11 -0500

On Aug 31, 2009, at 5:23 PM, Sean McBride wrote:

----
#import <Cocoa/Cocoa.h>

int main (void)
{
	NSString* foo = [NSString stringWithFormat:
		NSLocalizedString(@"%d days ago", @"some comment"),
		350];

	return 0;
}
----

$ gcc-4.2 -Wformat=2 -framework Cocoa test.m
test.m: In function 'main':
test.m:7: warning: format not a string literal, argument types not checked



Other than removing the warning, or hacking the headers in the SDK (to
add compiler decorations), anyone have any suggestions on how to rewrite
this code to work with that warning?

Why are you specifying -Wformat=2? That explicitly includes -Wformat- nonliteral, which is deliberately more strict than -Wformat-security.


You appear to be explicitly requesting warnings when you use a non- literal format string and then complaining when you get warnings that you're using a non-literal format string.

Just because the compiler has a warning doesn't mean it's a good idea to turn it on.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Snow Leopard bug?
  • Next by Date: Re: Adding Segmented Buttons to Toolbar.
  • Previous by thread: Re: "Format not a string literal and no format arguments"
  • Next by thread: Re: Snow Leopard bug?
  • Index(es):
    • Date
    • Thread