Boost logo

Boost Users :

Subject: Re: [Boost-users] Metaprogramming Question
From: John M. Dlugosz (mpbecey7gu_at_[hidden])
Date: 2012-02-11 02:17:38


On 2/10/2012 1:46 PM, Michael Schulze wrote:

> That is not a bug of gcc. It is right if it states that the
> interpretation could be done in two way either the else belongs to the
> first if or to the second one. However, you can make yourself and the
> compiler happy. Try the following.
>
> #define MY_FANCY_ASSERT(cond, str) \
> do { if (cond) {} else format(str) % __FILE__ % __LINE__ } while(0)
>
> With this you have encapsulated the if-else statement and the compiler
> has now no reasons to complain anymore.
>

How is that different from leaving off the do and while and just putting braces around the
whole thing?

> #define MY_FANCY_ASSERT(cond, str) \
> { if (cond) {} else format(str) % __FILE__ % __LINE__ }


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net