discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setter Gettor method style


From: Alexander Malmberg
Subject: Re: Setter Gettor method style
Date: Sun, 04 Aug 2002 17:01:13 +0200

[snip]
> -- All the Macros I read there are designed in a way like this:
> #define DESTROY(object)         ({ \
>    [...]
> })
> 
> Now I am not totally sure about this, but I've learnt (listening to
> some kernel developers) that one should always write multi line
> Macros in some slightly different way like this:
> 
> #define DESTROY(object)         do { \
>    if (object) \
>      [...]
> } while(0)
> 
> (http://www.rtems.com/rtems/maillistArchives/rtems-users/2001/august/msg00056.html)
> 
> I see that both work, so is there one that has some advantages? Or is
> it just personal preference what to use?

The '({' stuff is a gcc extension; 'do {...} while(0)' is portable.

- Alexander Malmberg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]