From owner-freebsd-chat Fri Feb 25 21:21:13 2000 Delivered-To: freebsd-chat@freebsd.org Received: from csla.csl.sri.com (csla.csl.sri.com [192.12.33.2]) by hub.freebsd.org (Postfix) with ESMTP id 2957137BC5C for ; Fri, 25 Feb 2000 21:21:07 -0800 (PST) (envelope-from molter@csl.sri.com) Received: from sofia.csl.sri.com (sofia.csl.sri.com [130.107.18.127]) by csla.csl.sri.com (8.9.1/8.9.1) with ESMTP id VAA06785 for ; Fri, 25 Feb 2000 21:21:06 -0800 (PST) From: Marco Molteni Received: (from molter@localhost) by sofia.csl.sri.com (8.9.3/8.8.7) id VAA05677 for freebsd-chat@FreeBSD.ORG; Fri, 25 Feb 2000 21:21:05 -0800 (PST) Date: Fri, 25 Feb 2000 21:21:05 -0800 To: freebsd-chat@FreeBSD.ORG Subject: Re: how to do this C preprocessor trick? Message-ID: <20000225212105.A5667@sofia.csl.sri.com> Mail-Followup-To: freebsd-chat@FreeBSD.ORG References: <20000225182432.A5017@sofia.csl.sri.com> <20000226001121.A20702@cc942873-a.ewndsr1.nj.home.com> <20000225214616.U21720@fw.wintelcom.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre4i In-Reply-To: <20000225214616.U21720@fw.wintelcom.net>; from bright@wintelcom.net on Fri, Feb 25, 2000 at 09:46:17PM -0800 Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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