[cfe-dev] warning: if statement has empty body

Pierre Habouzit madcoder at madism.org
Sun Mar 15 15:24:49 PDT 2009


On Sat, Mar 14, 2009 at 05:37:20AM +0000, रजनीश wrote:
> never mind then.
>   code expands to
> 	if (0) ;
> So what is the purpose of this kind of coding.

It's just bad, CF_OBJC_FUNCDISPATCH? should expand to (void)0 or
`do { } while (0)` or anything similar that the compiler will optimize
out and is a valid expression, when it's meant to do nothing.

Defining it to expand to nothing is just bad. For example, had you
written something like:

`if (CF_OBJC_FUNCDISPATCH(...), 10)` it would result in a compilation
failure instead of just a warning. Arguably this kind of coding style is
even worse, but ...

-- 
·O·  Pierre Habouzit
··O                                                madcoder at debian.org
OOO                                                http://www.madism.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090315/204ca481/attachment.sig>


More information about the cfe-dev mailing list