我需要使用宏来连接字符串以生成函数名称.
#define CONCAT(a,b,c) a ## b
int i=1;
CONCAT(a,i)
Run Code Online (Sandbox Code Playgroud)
这个代码给出ai了我想要的结果a1.
由于我的源代码中有许多函数,我不想枚举它们.
我的目标:
for(int i=0;i<100;i++)
{
Funi1();//here i should be from 0 to one hundred
Funi2();
Funi3();
Funi4();
..
}
Run Code Online (Sandbox Code Playgroud)
@Potatoswatter
我编写了一个脚本来扩展它,输出文件花费了一百行.@Eric Finn
小智 8
由于宏在预处理阶段被扩展,因此是不可能的.所以,它不能取变量和concat的值.