关于宏定义中的一点问题
下面是我直接按照别人的来写的,可是一直提示下面的错误,不明白为什么,有大神可以帮忙给指点一下吗?不胜感激!#include <stdio.h>
#define exchange(a,b)\
{\
/*宏定义中允许包含两道以上命令的情形,此时必须在最右边加上“\”*/
int t;\
t=a;\
b=a;\
t=b;\
}
int main(int argc, char *argv[])
{
int x=10;
int y=20;
printf("x=%d; y=%d",x,y);
exchange(x,y);
printf("x=%d;y=%d",x,y);
return 0;
}
--------------------配置: mingw5 - CUI Debug, 编译器类型: MinGW--------------------
检查文件依赖性...
正在编译 D:\Program Files\C-Free 5\appdata\samples\047.cpp...
[Error] D:\Program Files\C-Free 5\appdata\samples\047.cpp:5: error: expected constructor, destructor, or type conversion before '=' token
[Error] D:\Program Files\C-Free 5\appdata\samples\047.cpp:5: error: expected constructor, destructor, or type conversion before '=' token
[Error] D:\Program Files\C-Free 5\appdata\samples\047.cpp:5: error: expected constructor, destructor, or type conversion before '=' token
[Error] D:\Program Files\C-Free 5\appdata\samples\047.cpp:5: error: expected declaration before '}' token
构建中止 047: 4 个错误, 0 个警告