#include<stdio.h>
#define A(int x) printf("%d\n",x)
#define AS(A) A(20)
typedef struct{
int *m;
int n;
int k;
}st;
//static st sb[10] = {AS(A)}
int main()
{
AS(A);
return 0;
}
我收到如下错误。
Line 14: error: macro parameters must be comma-separated
请帮忙。
最佳答案
这与嵌套宏无关。问题是
#define A(int x) printf("%d\n",x)
您必须删除 int
部分。像这样:
#define A(x) printf("%d\n",x)
如果您保留 int
,预处理器会将其解释为另一个参数,这就是它告诉您的原因
Line 14: error: macro parameters must be comma-separated
因为期望:
#define A(int,x) printf("%d\n",x)
关于c - C 中的嵌套宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8064151/