Re: [RFC]: (void)0 instead of empty defines

From: Roman Divacky <rdivacky_at_freebsd.org>
Date: Mon, 15 Jun 2009 20:58:12 +0200
On Mon, Jun 15, 2009 at 11:38:33AM -0700, Sam Leffler wrote:
> Roman Divacky wrote:
> >hi
> >
> >in many places we do something like
> >
> >#ifdef SOMETHING
> >#define FOO some_code
> >#else
> >#define FOO
> >#endif
> >
> >
> >I propose to change the second FOO to (void)0 in many places to
> >
> >1) let this compile cleanly with clang. Clang warns in many places
> >about
> >		if (cond)
> >			FOO;
> >
> >which has empty if body
> >
> >2) enforces ; at the end of the expression
> >
> >this does not cost us nothing so I hope this change is ok.
> >
> >patch at: http://www.vlakno.cz/~rdivacky/void-zero.patch                   
> >
> >what do you think?
> >
> >roman
> >
> >p.s. there's also ACPI_DEBUG_PRINT in contrib/acpica which I hope
> >jkim might handle
> >  
> 
> Are you saying that:
> 
> if (cond)
>    ;
> 
> is considered worthy of a warning by the compiler?  Is it just "if" or 
> all conditional control constructs (e.g. while)?
> 
> I can image many instances of this construct arising from debugging 
> facilities.  This sounds like a stupid restriction and I would argue we 
> should just disable the warning.

it already found a bug in csup (recently fixed by lulf). It sure can be
disabled but I'd like it to be discussed a little bit more as it already
proved to be useful.

roman
Received on Mon Jun 15 2009 - 16:58:18 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:50 UTC