From owner-freebsd-hackers Fri Jun 5 11:01:00 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA10063 for freebsd-hackers-outgoing; Fri, 5 Jun 1998 11:01:00 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from zwei (zwei.siemens.at [193.81.246.12]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA10047 for ; Fri, 5 Jun 1998 11:00:47 -0700 (PDT) (envelope-from lada@pc8811.gud.siemens.at) Received: from pc8811.gud.siemens.at (root@[10.1.140.1]) by zwei with ESMTP id LAA27900; Fri, 5 Jun 1998 11:28:07 +0200 (MET DST) Received: from pc8811.gud.siemens.at (pc8811.gud.siemens.at [195.3.22.159]) by pc8811.gud.siemens.at (8.8.8/8.8.8) with ESMTP id LAA20561; Fri, 5 Jun 1998 11:26:17 +0200 (CEST) (envelope-from lada@pc8811.gud.siemens.at) Message-ID: X-Mailer: XFMail 1.2 [p0] on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <19980605152726.G768@freebie.lemis.com> Date: Fri, 05 Jun 1998 11:26:17 +0200 (CEST) Organization: Siemens Austria AG From: Marino Ladavac To: Greg Lehey Subject: Re: style(9) error? Cc: freebsd-hackers@FreeBSD.ORG, Chris Csanady Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 05-Jun-98 Greg Lehey wrote: > On Thu, 4 June 1998 at 16:22:22 -0500, Chris Csanady wrote: >> >> I would like to make use of a feature that style tells me I can use, but >> gcc tells me I can not.. >> >>> From style(9): >> >> es, it makes it easier to read. If the macro encapsulates a compound >> statement, enclose it in a ``do'' loop, so that it can safely be used >> in >> ``if'' statements. Any final statement-terminating semicolon should be >> supplied by the macro invocation rather than the macro, to make parsing >> easier for pretty-printers and editors. >> >> #define MACRO(x, y) do { >> #\ >> variable = (x) + (y); >> \ >> (y) += 2; >> \ >> } while(0) >> >> As far as I can tell, it is impossible to put a do loop in a if statement, >> or anything else. Is this correct? > > No. We have a case of misunderstanding here: the original poster asked whether if (MACRO(x, y)) foo(); else bar(); were allowed (which it is not, with the MACRO defined as it is), whereas you and the manpage are refering to if (foo()) MACRO(x, y); else MACRO(y, x); which is, and the do {} while() loop MACRO construct is necessary in order to allow for semicolons after the MACRO invocation in a true or false branches of an if statement. /Marino To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message