Date: Thu, 4 Jun 1998 23:16:11 -0700 (PDT) From: Julian Elischer <julian@whistle.com> To: Chris Csanady <cc@swing.ca.sandia.gov> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: style(9) error? Message-ID: <Pine.BSF.3.95.980604231026.16963A-100000@current1.whistle.com> In-Reply-To: <199806042122.QAA00625@swing.ca.sandia.gov>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.980604231026.16963A-100000>
