bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-


From: Paul Eggert
Subject: Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length
Date: Tue, 29 Nov 2011 14:13:07 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0

On 11/29/11 13:32, Eric Blake wrote:
>>    #if FEATURE_ENABLED
>> >     #define FEATURE_FORMAT "feature"
>> >    #else
>> >     #define FEATURE_FORMAT ""
>> >    #endif
>> >    ...
>> >    printf (buf, FEATURE_FORMAT);
> I assume you meant sprintf (buf, FEATURE_FORMAT), or printf
> (FEATURE_FORMAT)?

Yes, that's right.

Since my earlier example wasn't convincing enough, how
about this one?

#if FEATURE_ENABLED
 #define FEATURE_FORMAT_ARGS(a, b) "(%d, %s)" a, b
#else
 #define FEATURE_FORMAT_ARGS(a, b) ""
#endif
...
printf (FEATURE_FORMAT_ARGS (i, argv[i]);
...
snprintf (buf, sizeof buf, FEATURE_FORMAT_ARGS (i, argv[i]);

I wouldn't mind so much if I thought that -Wformat-zero-length
would be useful, but I can't think of a single likely
use case for it.  It's not like there's a real problem with
people writing 'printf ("");' when they should write nothing.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]