Re: Good C programming style



Sensei wrote:

> On 2005-10-10 15:31:40 +0200, Chris Dollin <kers@xxxxxxxxxx> said:
>
>> Sensei wrote:
>>
>>> So why I see so often something like:
>>>
>>> #define CEXCERPT do { \
>>> some(); \
>>> C_code(); \
>>> here(); \
>>> } while(0)
>>>
>>> Is it just some person thinking he would achieve more speed?
>>
>> No, it's some person arranging that their macro can be expanded
>> as CEXCERPT;
>>
>> without confusion. (I would have thought, even more likely
>> with a parameterised macro.)
>
>
> I understood why he does not use a ; at the end, but why someone would
> have such a big macro... is beyond my knowledge, something like the
> xge_whatever stuff I found... :)

How big is "big"?

#define NEEDS(mill, n) \
do { \
if (vm->myHeap->available < (Size) (n)) \
(FREEZE(), millRegenerate( mill ), MELT()); \
} while (0)

--
Chris "electric hedgehog" Dollin
"I know three kinds: hot, cool, and what-time-does-the-tune-start?"
.



Relevant Pages

  • Re: Good C programming style
    ... Sensei wrote: ... > I'm thinking about a good programming style, ... This is considered bad style for a macro because the macro argument is ... > The difference between stupidity and genius is that genius has its ...
    (comp.lang.c)
  • Re: Matrix with headers
    ... Sensei wrote: ... is it so difficult just to set the vanilla \bordermatrix to use custom parenthesis? ...
    (comp.text.tex)
  • Re: Good C programming style
    ... >> Sensei wrote: ... it's some person arranging that their macro can be expanded ... One reason to do this is to save the overhead of a function call. ...
    (comp.lang.c)
  • Re: Your favourite technique?
    ... BOW to your Sensei! ... MrTimm ... Prev by Date: ...
    (rec.martial-arts)
  • Re: C preprocessor
    ... > I came across the following macro in a program, ... The latter would be a way of writing a mask of 1's from ... Chris "electric hedgehog" Dollin ... Prev by Date: ...
    (comp.lang.c)