Am 29.08.2009 um 21:19 schrieb Quincey Morris:
So if you provide a string literal, there's no warning because it's
assumed you're not going to hard-code stray '%' characters in it. If
you provide arguments after the string (whether literal or not),
it's assumed you've made sure the string
Am 29.08.2009 um 21:25 schrieb Ken Thomases:
When you don't provide a constant format string but you do provide
arguments, it is assumed that you at least haven't made the most
common form of mistake. Your code seems to recognize that the first
argument is a format string which may require
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
On 8/29/09 4:00 PM, Ken Thomases said:
GCC knows about the standard formatting functions and applies the
analysis to them automatically, by default. However, it also allows
the application of the __attribute__((format ...)) decoration to user-
defined functions to have them checked in the same
After upgrading to snow leopard Xcode 3.2, I've starting getting
this warning on NSLogs -
NSLog(@Hello); // 'Format not a string literal and no format arguments'
NSLog(@Hello %@, name); // compiles fine
I must have some weird project setting somewhere since a new test
project didn't throw
On Aug 29, 2009, at 05:36, Jonathan del Strother wrote:
After upgrading to snow leopard Xcode 3.2, I've starting getting
this warning on NSLogs -
NSLog(@Hello); // 'Format not a string literal and no format
arguments'
NSLog(@Hello %@, name); // compiles fine
I must have some weird
Morrisquinceymor...@earthlink.net wrote:
On Aug 29, 2009, at 05:36, Jonathan del Strother wrote:
After upgrading to snow leopard Xcode 3.2, I've starting getting
this warning on NSLogs -
NSLog(@Hello); // 'Format not a string literal and no format
arguments'
NSLog(@Hello %@, name); // compiles
On Aug 29, 2009, at 10:36 AM, Quincey Morris wrote:
On Aug 29, 2009, at 05:36, Jonathan del Strother wrote:
After upgrading to snow leopard Xcode 3.2, I've starting getting
this warning on NSLogs -
NSLog(@Hello); // 'Format not a string literal and no format
arguments'
NSLog(@Hello
++
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
On Aug 29, 2009, at 11:54, Peter Duniho wrote:
Or is it implied that the compiler is doing compile-time
verification of the format string when a literal is provided?
Sort of, but not exactly. The first parameter to NSLog is *really* a
format string, not just a string. If an arbitrary
On Aug 29, 2009, at 1:54 PM, Peter Duniho wrote:
Am I reading the right documentation? On this page:
http://developer.apple.com/mac/library/releasenotes/Cocoa/Foundation.html
I see this text:
Foundation APIs which take string format arguments (APIs
such as initWithFormat:, NSLog(),
On Aug 29, 2009, at 2:19 PM, Quincey Morris wrote:
On Aug 29, 2009, at 11:54, Peter Duniho wrote:
Or is it implied that the compiler is doing compile-time
verification of the format string when a literal is provided?
Sort of, but not exactly.
Actually, yes exactly.
So if you provide a
On Aug 29, 2009, at 12:31, Ken Thomases wrote:
No such thing is assumed. If you provide a string literal, the
compiler actual checks it and the arguments to make sure they're
consistent with each other.
I expressed myself badly. Because that check produces a different
warning, I was
On Aug 29, 2009, at 3:24 PM, Quincey Morris wrote:
It's actually not clear (to me) whether the two warnings are
controlled by the same compiler options. AFAIK -Wno-format (which
used to be the default in the build setting) would turn off the type
mismatch warning, but I don't know whether
14 matches
Mail list logo