Re: wprintf does not honor "Typecheck calls to printf/scanf" setting
Re: wprintf does not honor "Typecheck calls to printf/scanf" setting
- Subject: Re: wprintf does not honor "Typecheck calls to printf/scanf" setting
- From: Jens Ayton <email@hidden>
- Date: Sun, 6 Dec 2009 20:41:51 +0100
On Dec 4, 2009, at 17:08, Sean McBride wrote:
> On 12/4/09 12:43 PM, Ben Staveley-Taylor said:
>>
>> I have just fixed a bug in my own code which would have been spotted far
>> earlier by a compiler warning. I was not passing enough parameters to printf.
>>
>> If I do :
>> printf("%s%s", "test");
>> I correctly get the warning "warning: too few arguments for format"
>>
>> But as I am using wchar_t versions of everything (for cross-platform
>> code reasons) I do this:
>> wprintf(L"%S%S", L"test");
>> And not a peep from the compiler. No warning. Just a crash when you run it.
>>
>> I have the "Typecheck calls to printf/scanf" option on. Is there another
>> option to set to enable the warning for wchar_t code?
>
> I don't think so. That warning only works in some cases, as you have
> seen. It only started working with NSString functions in 10.6 for
> example. It also doesn't work with the various SenTestingKit
> functions. You'll have to file a bug and/or try a different compiler.
Note that you can mark functions which take certain types of format arguments using gcc's __attribute__ extension. http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
The Snow Leopard compilers accept __NSString__ for the "archetype" argument, and there's an NS_FORMAT_FUNCTION(string-index, first-to-check) macro in NSObjCRuntime.h.
--
Jens Ayton
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden