error C3861怎么办
#include <iostream>using namespace std;
#define STR ( a)#a
#define CAT(a,b)a##b
int main (void)
{
int xy=100;
cout<<STR (ABCD)<<endl;
cout<<CAT(x,y)<<endl;
return 0;
}
为什么会编译的时候会出现(12): error C3861: “a”: 找不到标识符
该怎么办呢
本帖最后由 メ㊣逆ご帅☆ 于 2014-7-31 20:55 编辑
#define STR ( a)#a(STR和(a)之间多了空格)
被解释成把STR作为宏名且无参数。后面作为宏的内容
删除空格就行
#include <iostream>
using namespace std;
#define STR(a)#a
#define CAT(a,b)a##b
int main (void)
{
int xy=100;
cout<<STR(ABCD)<<endl;
cout<<CAT(x,y)<<endl;
return 0;
}
页:
[1]