(void)foo or __unused foo ?
Luigi Rizzo
rizzo at iet.unipi.it
Fri Jul 27 12:31:36 UTC 2012
On Fri, Jul 27, 2012 at 11:20:48AM +0000, Poul-Henning Kamp wrote:
> In message <20120727093824.GB56662 at onelab2.iet.unipi.it>, Luigi Rizzo writes:
>
> >The alternative way to avoid an 'unused' warning from the compiler
> >is an empty statement
> >
> > (void)foo;
>
> The thing I don't like about this form, is that it doesn't communicate
> your intention, only your action.
>
> Somewhere down my TODO list I have an item to propose instead:
>
> typedef void unused_t;
>
> int main(int argc, char **argv)
> {
>
> (unused_t)argc;
> (unused_t)argv;
> return (0);
> }
i certainly like this better, my only concern is that some other
platform might come with an incompatible usage of the name 'unused_t'
same as it happened for __unused, and we are back with the problem.
A comment might be used to explain the intention in even more detail:
(void)foo; /* unused on XyBSD and Babbage-OS */
cheers
luigi
More information about the freebsd-current
mailing list