【发布时间】:2013-03-26 11:10:56
【问题描述】:
我遇到了一个宏问题,我不知道为什么。
这里是宏:
#define WAIT(condition, max_time) \
do { \
int int_loop_wait=0; \
while(1) \
{ \
if(condition) { break; } \
sleep(1); \
if(int_loop_wait>=max_time) { break; } \
int_loop_wait++; \
} \
} while(0) \
我收到了错误
“期望声明”行“ if(condition) { break; }”
有人理解这个错误吗?
【问题讨论】:
-
您没有在循环内更改
int_loop_wait。max_time无效。 -
真的!我现在改变它。我让你更新
-
@Krishnabhadra 是宏,所以不要分号(代码里会加)
-
@Krishnabhadra,如果你想在代码中的某处写
WAIT(condition, max_time);,则不需要; -
宏调用在哪里?