Re: New book - 'C of Peril'
From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 12/05/04
- Next message: Chris Torek: "Re: [Q] about free(ptr)"
- Previous message: Chris Torek: "Re: Algorithm required."
- In reply to: Malcolm: "Re: New book - 'C of Peril'"
- Next in thread: Malcolm: "Re: New book - 'C of Peril'"
- Reply: Malcolm: "Re: New book - 'C of Peril'"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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!
- Next message: Chris Torek: "Re: [Q] about free(ptr)"
- Previous message: Chris Torek: "Re: Algorithm required."
- In reply to: Malcolm: "Re: New book - 'C of Peril'"
- Next in thread: Malcolm: "Re: New book - 'C of Peril'"
- Reply: Malcolm: "Re: New book - 'C of Peril'"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|