我编写了以下 C 代码:
#define MAX_T(a,b,d) \
{ int len = (d);printf("len %d", len);}
int main()
{
//MAX_T(10,30, smgarbage)
MAX_T(10,30, len)
}
当我注释掉MAX_T(10,30, smgarbage)
并运行它时,它会输出len 24
. 当我注释掉MAX_T(10,30, len)
并运行时,MAX_T(10,30, smgarbage)
我得到这个编译器错误:
test.c: In function 'main':
test.c:34: error: 'smgarbage' undeclared (first use in this function)
test.c:34: error: (Each undeclared identifier is reported only once
test.c:34: error: for each function it appears in.)
执行时MAX_T(10,30, len)
为什么没有出现编译器错误?是声明int len = (d);
造成的吗?如何?