Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2000-11-20 11:11:46


Wow, thanks :)

On Mon, 20 Nov 2000, Moore, Paul wrote:
>
> The usual reason for do...while is that {...} is not "quite" a statement.
> Example
>
> #define test1 do { int n = 2; (void)n } while (0)
> #define test2 { int n = 2; (void)n }
>
> if (0)
> test1;
> else
> /* whatever */;
>
> if (0)
> test2;
> else
> /* whatever */;
>
> The second fails (dangling else) as test2; expands to {...}; and the extra ;
> is a null statement which stops the else from coming straight after the
> if...
>
> I'm depressed that I know this...
> Paul.

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk