Re: (void)foo or __unused foo ?

From: Luigi Rizzo <rizzo_at_iet.unipi.it>
Date: Fri, 27 Jul 2012 14:51:34 +0200
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
Received on Fri Jul 27 2012 - 10:31:36 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:29 UTC