Re: (void)foo or __unused foo ?

From: Poul-Henning Kamp <phk_at_phk.freebsd.dk>
Date: Fri, 27 Jul 2012 11:20:48 +0000
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);
	}

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk_at_FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.
Received on Fri Jul 27 2012 - 09:28:20 UTC

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