From owner-freebsd-chat  Sat Feb 26 14:32:20 2000
Delivered-To: freebsd-chat@freebsd.org
Received: from mail2.x-treme.gr (mail2.x-treme.gr [212.120.196.24])
	by hub.freebsd.org (Postfix) with ESMTP id 3808A37B596
	for <freebsd-chat@FreeBSD.ORG>; Sat, 26 Feb 2000 14:31:40 -0800 (PST)
	(envelope-from keramida@ceid.upatras.gr)
Received: from hades.hell.gr (pat58.x-treme.gr [212.120.197.250])
	by mail2.x-treme.gr (8.9.3/8.9.3/IPNG-ADV-ANTISPAM-0.1) with ESMTP id AAA13995;
	Sun, 27 Feb 2000 00:30:26 +0200
Received: by hades.hell.gr (Postfix, from userid 1001)
	id 0CBC8DD283; Sat, 26 Feb 2000 23:23:24 +0200 (EET)
Date: Sat, 26 Feb 2000 23:23:24 +0200
From: Giorgos Keramidas <keramida@ceid.upatras.gr>
To: cjclark@home.com
Cc: Alfred Perlstein <bright@wintelcom.net>,
	Marco Molteni <molter@csl.sri.com>, freebsd-chat@FreeBSD.ORG
Subject: Re: how to do this C preprocessor trick?
Message-ID: <20000226232324.C99617@hades.hell.gr>
Reply-To: keramida@ceid.upatras.gr
References: <20000225182432.A5017@sofia.csl.sri.com> <20000226001121.A20702@cc942873-a.ewndsr1.nj.home.com> <20000225214616.U21720@fw.wintelcom.net> <20000226003741.C20702@cc942873-a.ewndsr1.nj.home.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Mailer: Mutt 1.0i
In-Reply-To: <20000226003741.C20702@cc942873-a.ewndsr1.nj.home.com>; from cjc@cc942873-a.ewndsr1.nj.home.com on Sat, Feb 26, 2000 at 12:37:41AM -0500
X-PGP-Fingerprint: 62 45 D1 C9 26 F9 95 06  D6 21 2A C8 8C 16 C0 8E
X-Phone-Number: +30-94-6203692, +30-93-2886457
X-Address: Theodorou Kirinaiou 61, 26334 Patra, Greece
Sender: owner-freebsd-chat@FreeBSD.ORG
Precedence: bulk
X-Loop: FreeBSD.org

On Sat, Feb 26, 2000 at 12:37:41AM -0500, Crist J. Clark wrote:
> 
> Why a,
> 
>   do { <stuff> } while(0)
> 
> Rather than just,
> 
>   { <stuff> }
> 
> That's how I group multi-statement macros, but that does not work for
> this one.

One fairly good reason that I can clearly remember is that, with the
extra do { .. } while (0) wrapping, one gets the extra benefit of being
able to define properly scoped local variables within the macro body.

-- 
Giorgos Keramidas, < keramida @ ceid . upatras . gr >
For my public PGP key: finger keramida@diogenis.ceid.upatras.gr
PGP fingerprint, phone and address in the headers of this message.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message