On 17/08/11 09:49, Marijn wrote:
-----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


I was quite amazed to read about this bug in Racket and I was going to suggest exactly the same thing. All Racket code should ensure no macro expands to more than one expression. Use `do { ... } while(0)' pattern.

Consider this email just a reinforcement of Marijn' suggestion.

--
PMatos

_________________________________________________
 For list-related administrative tasks:
 http://lists.racket-lang.org/listinfo/dev

Reply via email to