On Tuesday 01 August 2006 16:54, Gabriel Dos Reis wrote:
> "Denis Vlasenko" <[EMAIL PROTECTED]> writes:
> | if()
> | (void)0; /* do nothing */
> |
> | will make you happy.
>
> No, I'm not. I find it Very Silly.
Do you prefer buggy code like this?
| > > After a couple hours debugging code, I figured our an if() somewhere
| > > had a trailing ; like this:
| > >
| > > if (memcmp(p, COMMUNITY, strlen(COMMUNITY)) != 0);
| > > continue; /* failed */
| > >
| > > The code above will always reach "continue" even when memcmp() == 0.
We want gcc to warn about such cases (about empty if's, that is).
Thus we need to have non-empty statement in if() body, always.
Of course you do not write "if(expr) (void)0;" directly,
it's what compiler sees.
Usage is
#if ....
#define do_something() ((void)0)
#endif
...
if(expr) do_something();
--
vda