我正在尝试做这样的事情
#define GETCART1 0;
#define GETCART2 1;
void helper(int *Array,int length,int counter, int option){
if (length > counter){
switch(option){
case (GETCART1) :
break;
}//switch
}
}
当我将 GETCART1
替换为 0
时出现编译错误,它工作正常。这是为什么?
最佳答案
从定义中删除分号。
#define GETCART1 0;
^ Drop this
如果不这样做,在预处理器完成时,您的代码最终将如下所示:
switch(option){
case (0;) :
^
break;
}
关于c - 使用 visual studio 2010 在 C 中使用宏的 switch 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8657061/