On 02/07/2009 09:56 AM, Michael ODonnell wrote:
In the kernel code you presented, it would be functionally equivalent, but not syntactically or semantically. The bottom line is that in the section of code you presented, what was important was to establish a block so a variable could be defined. Adding the do <statement> while(0) is just adding some extraneous code that would be most probably optimized out, but even if it is not, it is in an error condition.But if you change the macro to: #define b0rken(x) ({return x;}) you will find that the compiler likes it again.I mistakenly interpreted your statement that the two constructions are equivalent:What I see confufsing is: do { ... } while(0);[...]{ ... } would be equivalent to above...to mean that you believe that they are generally interchangeable. Since that do-while(0) trick is in fairly common usage (often inside macros) I just wanted to illustrate a situation where they're not.
-- Jerry Feldman <g...@blu.org> Boston Linux and Unix PGP key id: 537C5846 PGP Key fingerprint: 3D1B 8377 A3C0 A5F2 ECBB CA3B 4607 4319 537C 5846
signature.asc
Description: OpenPGP digital signature
_______________________________________________ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/