[racket-dev] [plt] Push #23267: master branch updated

From: Marijn (hkBst at gentoo.org)
Date: Wed Aug 17 04:49:53 EDT 2011

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/16/11 20:54, Stephen Bloch wrote:
> Wouldn't it be even better to put curly-braces around the body of the
> C macro, so people using it don't have to know that it expands into
> multiple statements?

I read a long time ago (I think it was on LWN, but I can't find the
article) about some tricks that are used in the linux kernel to mitigate
weaknesses of the C preprocessor. You wrap multiple statement macros in
"do {" "} while(0)", so that you don't have to think about whether you
need curly braces and it will absorb (and need) a semicolon, so that it
won't break your if-statements. You can read more about it here:

https://www.securecoding.cert.org/confluence/display/seccode/PRE10-C.+Wrap+multi-statement+macros+in+a+do-while+loop

HTH,

Marijn

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5LgLEACgkQp/VmCx0OL2xATgCeIdh5rtE6SqCmKXZ6UYxBBTDV
1xIAoLlXT3M9od0S1T3pNnoO0b8jAu+d
=Ea5K
-----END PGP SIGNATURE-----


Posted on the dev mailing list.