Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 04 Jun 1998 16:22:22 -0500
From:      "Chris Csanady" <cc@swing.ca.sandia.gov>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   style(9) error?
Message-ID:  <199806042122.QAA00625@swing.ca.sandia.gov>

next in thread | raw e-mail | index | archive | help

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806042122.QAA00625>