empty function macros
Alexander Best
arundel at freebsd.org
Sun Jan 30 22:37:07 UTC 2011
On Sun Jan 30 11, Gary Jennejohn wrote:
> On Sun, 30 Jan 2011 17:29:41 +0000
> Alexander Best <arundel at freebsd.org> wrote:
>
> > hi there,
> >
> > i noticed freebsd has a few of the following macros:
> >
> > #define FUNC(sb)
> >
> > when you do something like
> >
> > if (cond)
> > FUNC(i)
> >
> > the compiler complains about an if statement with an empty body. any sensible
> > way of dealing with this issue?
> >
> > i saw some reiserfs code which does the following to silence compilers:
> >
> > #define FUNC(sb) do { } while (0)
> >
>
> What happens if you treat it like a real function call and put ';'
> after it?
sorry this was my fault. it should have actually been:
if (cond)
FUNC(i);
basically, since FUNC evaluates to nothing this results in
if (cond)
;
while gcc doesn't complain, clang does.
cheers.
alex
>
> --
> Gary Jennejohn (gj@)
--
a13x
More information about the freebsd-hackers
mailing list