【发布时间】:2015-08-06 08:57:11
【问题描述】:
我使用## 运算符连接两个数字。代码在我使用变量时出错,但在我直接输入时工作正常。
给出一个错误。
[错误] 'xy' 未声明(在此函数中首次使用)
#include<stdio.h>
#define join(a, b) a##b ;
int main()
{
int x = 10;
int y = 5;
int res ;
res = join(x, y);
printf("%d",res) ;
return 0 ;
}
工作正常:
#include<stdio.h>
#define join(a, b) a##b ;
int main()
{
int res ;
res = join(99, 10);
printf("%d",res) ;
return 0 ;
}
【问题讨论】:
标签: c macros concatenation preprocessor-directive