Subject: Re: Question on macros...
To: None <tech-kern@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 02/26/2007 10:16:02
> #define somemacro(x) \
>    do { \
>      somestuff; \
>    } while (0)

> Now, why the do-while loop here?

	if (something)
		somemacro(x);
	else
		....

This is a syntax error if somemacro() is { ... } bracketed.  The
do-while makes it eat a semicolon exactly when it should, while not
affecting control flow.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B