Re: New book - 'C of Peril'

From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 12/05/04


Date: Sun, 05 Dec 2004 19:41:19 GMT

Malcolm wrote:
> "Arthur J. O'Dwyer" <ajo@nospam.andrew.cmu.edu> wrote
>>
>>>> #define foo(x) do { bar(x); baz(x); } while(0)
>>>
>>> Anyone know if there's a way to do this without relying on
>>> do/while/if/for (etc)?
>>
>> Nope. But why does it matter? 'do' is just as much a part of
>> the language as the left parenthesis, and it always has been.
>>
> It's a minor irritation. By itself it doesn't matter much, but
> the cumulative effect of many minor irritations is that code
> becomes hard to read, and thus more expensive to maintain.

Not at all. The purpose of using it is exactly the opposite - to
allow the macro to be used in normal C contexts without creating
obscure syntax errors in the final code, or requiring special
considerations such as adding or omitting semicolons.

As far as reading the original macro definition is concerned, this
is a well known method, and should not cause any concern
whatsoever.

-- 
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!


Relevant Pages

  • Re: Parenthesis - to use or not to use?
    ... It isn't a matter of taste. ... It is part of the syntax of the language. ... > use parenthesis." ...
    (microsoft.public.excel.programming)
  • Re: New Bireli vid duo with John McLaughlin
    ... both titles with the Blue Trane option in parenthesis. ... there is the matter of the title's double entendre intent which means ...
    (rec.music.makers.guitar.jazz)
  • Re: New Bireli vid duo with John McLaughlin
    ... both titles with the Blue Trane option in parenthesis. ... there is the matter of the title's double entendre intent which means ...
    (rec.music.makers.guitar.jazz)
  • Re: Detecting a running application - FAQ Change?
    ... Allow me to reiterate some context. ... > function call the parenthesis merely indicate modifiers to the ... > function instance. ... Whether it matters, doesn't matter. ...
    (comp.lang.pascal.delphi.misc)
  • Re: New book - C of Peril
    ... >> Anyone know if there's a way to do this without relying on ... It's a minor irritation. ... By itself it doesn't matter much, but the cumulative effect of many minor ...
    (comp.lang.c)