[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] avoid misc. warnings
From: |
Bruno Haible |
Subject: |
Re: [PATCH] avoid misc. warnings |
Date: |
Thu, 5 Feb 2009 00:43:18 +0100 |
User-agent: |
KMail/1.9.9 |
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.
Bruno