[Mono-list] Style

Radek Doulík rodo@ximian.com
01 Mar 2002 12:02:12 -0500


On Pá, 2002-03-01 at 11:44, Dietmar Maurer wrote:
> On Fri, 2002-03-01 at 17:32, Radek Doulík wrote:
> 
> > #define MY_MACRO \
> > 	foo (); \
> > 	bar ()
> > 
> > if (x)
> > 	MY_MACRO;
> 
> I would never define a macro that way. Instead use something like:
> 
> #define do { foo(); bar (); } while (0)
> 
> and you will never have such problems.

Yeah, I've seen this in your code.

I've take a look in glib.h, how are multi-commands macros handled and
there are G_STMT_START, G_STMT_END macros defined, which could work even
better. Anyway, sometimes you have to use "alien" code and in this case
you will be safe with if (...) { EVIL_MACRO; }

Until now I used this "evil" style, so I am going to start using
G_STMT_... macros in my code ;-)

Cheers
rodo