Hello, world!

2007-03-11

do { } while(0)

[c-faq]What's the best way to write a multi-statement macro?より引用

#define MACRO(arg1, arg2) do { \
 /* declarations */ \
 stmt1;   \
 stmt2;   \
 /* ... */  \
 } while(0) /* (no trailing ; ) */
When the caller appends a semicolon, this expansion becomes a single statement regardless of context.
cf.[URL]
comp.lang.c Frequently Asked Questions
cf.[BOOK]
0201845199
C Programming Faqs: Frequently Asked Questions
Steve Summit