News for hackers. Stuff that matters.
Re:Tips on writing C macros by michaelfairley on Tuesday August 04, 2009 @09:03PM (#742575)
With your code, placing a semicolon after the macro leads to a compile error. Semicolons are not valid after arbitrary blocks, but it is acceptable to place them after do-while loops.

It's much nicer to be able to call "MYMACRO(1, 2, 3);" than it is to have to remember to leave the semi-colon off.

Re:Tips on writing C macros by paulbaumgart on Tuesday August 04, 2009 @09:21PM (#742607)
It compiles fine on GCC. For other compilers, the Wikipedia page I linked offers the caveat:

"This construct is not legal ANSI C; both the typeof keyword, and the construct of placing a compound statement within parentheses, are non-standard extensions implemented in the popular GNU C compiler (GCC)."