bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] avoid misc. warnings


From: Pádraig Brady
Subject: Re: [PATCH] avoid misc. warnings
Date: Thu, 5 Feb 2009 10:01:51 +0000
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

Bruno Haible wrote:
> Jim Meyering wrote:
>> I wrote these changes some time ago, and
>> am going to push them shortly.
>>
>> +#undef UNUSED_PARAM
>> +#ifdef __linux__
>> +# define UNUSED_PARAM _UNUSED_PARAMETER_
>> +#else
>> +# define UNUSED_PARAM
>> +#endif
>> +
>> ...
>>
>> +#undef UNUSED_PARAM
>> +#ifdef GETFSTYP
>> +# define UNUSED_PARAM
>> +#else
>> +# define UNUSED_PARAM _UNUSED_PARAMETER_
>> +#endif
>> +
> 
> Now this gets really ugly. Not only because a macro with the same name is 
> being
> undefined and redefined repeatedly, but also because the #if conditions for
> this macro must be the same as the #if conditions inside the function's body.
> When they get out of sync, the warning will reappear.
> 
> The other way to silence this warning is a statement
>   (void)param;
> in the function's body. (Or was there some problem with that? I just tested
> gcc 2.95.3 to 4.3.2, and in all versions such a void cast makes the warning
> disappear.)
> 
> Bottom line: Whenever the _UNUSED_PARAMETER_ macro cannot be used
> unconditionally, I would use a cast to void.

I have to agree. In that case _UNUSED_PARAMETER_ is really misnamed,
and would have been better as _MAYBE_UNUSED_.
For the case where you know parameters will be unused due to a #define for e.g.
I think it's better to cast to (void) in the function body as you say.

cheers,
Pádraig.




reply via email to

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