Date: Fri, 27 Jul 2012 23:41:10 -0700 From: Tim Kientzle <tim@kientzle.com> To: Luigi Rizzo <rizzo@iet.unipi.it> Cc: current@freebsd.org Subject: Re: (void)foo or __unused foo ? Message-ID: <B86B2D65-25E3-4887-9203-AFED9563CE51@kientzle.com> In-Reply-To: <20120727093824.GB56662@onelab2.iet.unipi.it> References: <20120727093824.GB56662@onelab2.iet.unipi.it>
next in thread | previous in thread | raw e-mail | index | archive | help
On Jul 27, 2012, at 2:38 AM, Luigi Rizzo wrote: >=20 > The alternative way to avoid an 'unused' warning from the compiler > is an empty statement >=20 > (void)foo; >=20 > that the compiler hopefully optimizes away. I learned the void-cast convention many years ago. I used it throughout the libarchive code and have yet to run into any problems. I always use it in exactly this form (with the exact comment here) so that I can easily search on it: int foo(int a) { (void) a; /* UNUSED */ =85 } I agree with PHK that it would be nice to express this intent in a way that static checkers could verify. I also agree that having static checkers interpret comments is Evil. But I have yet to see any alternative that was as straightforward and widely-supported as this one. Every other viable alternative seems to require tangled clumps of macros. Tim
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B86B2D65-25E3-4887-9203-AFED9563CE51>