From owner-freebsd-hackers Thu Jun 4 23:18:36 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA14662 for freebsd-hackers-outgoing; Thu, 4 Jun 1998 23:18:36 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from alpo.whistle.com (alpo.whistle.com [207.76.204.38]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA14638 for ; Thu, 4 Jun 1998 23:18:25 -0700 (PDT) (envelope-from julian@whistle.com) Received: (from daemon@localhost) by alpo.whistle.com (8.8.5/8.8.5) id XAA22773; Thu, 4 Jun 1998 23:16:18 -0700 (PDT) Received: from current1.whistle.com(207.76.205.22) via SMTP by alpo.whistle.com, id smtpd022766; Fri Jun 5 06:16:17 1998 Date: Thu, 4 Jun 1998 23:16:11 -0700 (PDT) From: Julian Elischer To: Chris Csanady cc: freebsd-hackers@FreeBSD.ORG Subject: Re: style(9) error? In-Reply-To: <199806042122.QAA00625@swing.ca.sandia.gov> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG not th econditional part, the THEN clause.. e.g. if (condition) MACRO(x); else MACRO2(y); evaluates correctly to: if (condition) do { sdfdfsg; sdfghdghh; } while (0); else do { ffdgdfsgs; sdfgsdfgsIdg; } while (0); which is what you require, Hopefully the compiler will remove the un-needed loping code. (certainly it will since this is so commmon.) julian On Thu, 4 Jun 1998, 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? I always thought that blocks evaluated > to their last statements, but it seems not.. > > Chris Csanady > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message