Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jul 2012 14:51:34 +0200
From:      Luigi Rizzo <rizzo@iet.unipi.it>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        current@freebsd.org
Subject:   Re: (void)foo or __unused foo ?
Message-ID:  <20120727125134.GA58187@onelab2.iet.unipi.it>
In-Reply-To: <9654.1343388048@critter.freebsd.dk>
References:  <20120727093824.GB56662@onelab2.iet.unipi.it> <9654.1343388048@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jul 27, 2012 at 11:20:48AM +0000, Poul-Henning Kamp wrote:
> In message <20120727093824.GB56662@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120727125134.GA58187>