warning about %s in format string

James Walker

Clang has a warning option, -Wcstring-format-directive, that produces a warning "Using %s directive in NSString which is being passed as a formatting argument to the formatting method" on a line like:

NSString* x = [NSString stringWithFormat: @"File %s", __FILE__];

Can someone please explain to me why this is something worth avoiding, or worth warning about?  I tried Googling, couldn't find anything.

Join cocoa@apple-dev.groups.io to automatically receive all group messages.