Date: Fri, 25 Feb 2000 21:21:05 -0800 From: Marco Molteni <molter@csl.sri.com> To: freebsd-chat@FreeBSD.ORG Subject: Re: how to do this C preprocessor trick? Message-ID: <20000225212105.A5667@sofia.csl.sri.com> In-Reply-To: <20000225214616.U21720@fw.wintelcom.net>; from bright@wintelcom.net on Fri, Feb 25, 2000 at 09:46:17PM -0800 References: <20000225182432.A5017@sofia.csl.sri.com> <20000226001121.A20702@cc942873-a.ewndsr1.nj.home.com> <20000225214616.U21720@fw.wintelcom.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 25 Feb 2000, Alfred Perlstein wrote:
> One of the nasty side effects is that this makes the macro expand to
> multiple statements.
>
> what's so bad about that?
>
> if (foo < 0)
> errmsg("foo < 0");
>
> Macros that expand to multiple statements ought to be enclosed in a
> do { } while(0) loop.
Alfred,
I saw many macros in the kernel sources enclosed in a do {} while (0)
loop. Could you explain why
> Macros that expand to multiple statements ought to be enclosed in a
> do { } while(0) loop.
Thanks
Marco
--
Marco Molteni "rough consensus and running code"
SRI International, System Design Laboratory
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000225212105.A5667>
