• 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: Jay Reynolds Freeman <email@hidden>
  • Date: Sat, 29 Aug 2009 12:13:47 -0700

As a possibly useful aid to understanding, I have seen what is very likely a related problem while compiling with llvm-gcc-4.2 from the command line; the problem there had to do with strict error checking of places where the current formal declaration of a function such as "fprintf" expects a format string, and where the source code in question provided not a literal string (C string) but a pointer to one, and also did not provide any extra arguments to be formatted. Thus for example, a command-line compile of the form

    /Developer/usr/bin/llvm-gcc-4.2  -o bug bug.c++

in which the code contains the lines:

    const char *formatString = "The answer is forty-two\n";
    fprintf( stdout, formatString );
    fputs( formatString, stdout	);

generates the warning

bug.c++: In function ‘int main()’:
bug.c++:11: warning: format not a string literal and no format arguments


for the line using fprintf, but no warning for the line using fputs.

See the g++ documentation for Wno_format, which I found a little confusing ... :-)

I also saw that same error message in Xcode compiles (Snow Leopard / Xcode 3.2, using llvm-gcc-4.2) of ".mm" files in which I had happened to use "fprintf" or "printf" in the offending manner. In those cases, I was able to toggle the warning by checking and unchecking the box for "Typecheck Calls to printf/scanf", which is in the "LLVM GCC 4.2 - Warnings" section of the build tab in the Xcode information window for the target in question.

--  Jay Reynolds Freeman
---------------------
email@hidden
http://web.mac.com/jay_reynolds_freeman (personal web site)


_______________________________________________

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


References: 
 >"Format not a string literal and no format arguments" (From: Jonathan del Strother <email@hidden>)
 >Re: "Format not a string literal and no format arguments" (From: Quincey Morris <email@hidden>)
 >Re: "Format not a string literal and no format arguments" (From: Jonathan del Strother <email@hidden>)

  • Prev by Date: Re: "Format not a string literal and no format arguments"
  • Next by Date: Re: "Format not a string literal and no format arguments"
  • Previous by thread: Re: "Format not a string literal and no format arguments"
  • Next by thread: Re: "Format not a string literal and no format arguments"
  • Index(es):
    • Date
    • Thread