【发布时间】:2011-09-27 13:42:30
【问题描述】:
可能的重复:
Why are there sometimes meaningless do/while and if/else statements in C/C++ macros?
What's the use of do while(0) when we define a macro?
有没有区别
#define MACRO(x) \
{ \
... \
}
和
#define MACRO(x) \
do { \
... \
} while(0)
?
【问题讨论】:
-
有没有办法让asker关闭?
-
我不确定我是否同意这个问题专门询问为什么 {} while(0) 但没有将它与看起来更干净的 {} 进行比较,否则您可能会使用