<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 25, 2012, at 10:41 AM, Jean-Daniel Dupas wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>Le 25 janv. 2012 à 18:33, jahanian a écrit :<br><br><blockquote type="cite"><br></blockquote><blockquote type="cite">On Jan 24, 2012, at 4:39 PM, Jean-Daniel Dupas wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">Hi,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">3-macros: In Obj-C and CoreFoundation, the recommended way to localize string are respectively to use NSLocalizedString(key, comment) and CFCopyLocalizedString(key, comment) macros family.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">It is common to use these macros as format string, but as they expand to method/function call, clang will warn about "non literal string" used as format string.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">So, this patch is a tentative to prevent diagnostic for this common usage. It inhibits the "non literal string format" diagnostic when the format type if NS/CFstring and the format argument is a macro expansion.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Note that while the CFCopyLocalizedString() expands to a function properly tagged with the "format_arg" attribute, we can't rely on it, because interpreting the 'key' parameter as a format string is incorrect IMHO.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">It is a common practice to use some kind of descriptive name for the key (i.e. "UNEXPECTED_ERROR_TITLE") instead of the string value ("An unexpected error occurred: %@").<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Moreover, NSLocalizedString() does not use the "format_arg" attribute.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I don't seem to be getting the warning on the test case, and I don't think you have yet checked in the patch.<br></blockquote><br>You're right. The tested warning is not enabled by default, and I forgot to add it to the test command line (or to enable it using pragma diagnostic).<br>I attach an updated version of the remaining patch with this issue fixed.<br></div></blockquote><div><br></div>This patch is OK for the purpose you mentioned.</div><div>- Fariborz</div><div><br><blockquote type="cite"><div><br><blockquote type="cite">- Fariborz<br></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#670a05"><br></font></blockquote></div></blockquote></div><br></body></html>