题目中的警告是gcc产生的: 当函数参数中有stuct XXX类型, 且该类型的定义出现在参数声明的后面.
下面的例子模拟这个警告:
/home/me/mjntest>cat t1.c
int f(struct S);
struct S {
int name;
};
int main() {
return 0;
}
/home/me/mjntest>gcc t1.c
t1.c:1: warning: 'struct S' declared inside parameter list
t1.c:1: warning: its scope is only this definition or declaration, which is probably not what you want
把函数f的声明放到struct S的定义后面, 则不会再产生警告:
/home/me/mjntest>cat t1.c
struct S {
int name;
};
int f(struct S);
int main() {
return 0;
}
/home/me/mjntest>gcc t1.c
/home/me/mjntest>
References:
stackoverflow.com: warning: ‘struct user_data_s’ declared inside parameter list