[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]![]() C Programming Faqs: Frequently Asked Questions Steve Summit |
