我正在尝试使用nftw处理目录下的一些文件
#include <ftw.h>
#include <stdio.h>
int wrapper(const char * fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) {
printf("File %d\n", ftwbuf->base);
return(0);
}
int main(int argc, char ** argv) {
const char *name;
int flags = 0;
name = argv[1];
nftw(name, wrapper, 20, flags);
return 0;
}
当我编译 (gcc kconfig_parser.c -o parser) 时,我收到了这个警告和这个错误..
kconfig_parser.c:5: warning: ‘struct FTW’ declared inside parameter list
kconfig_parser.c:5: warning: its scope is only this definition or declaration, which is probably not what you want
kconfig_parser.c: In function ‘wrapper’:
kconfig_parser.c:6: error: dereferencing pointer to incomplete type
我检查了结构的定义和回调的原型,还有一些例子,应该没问题......我做错了什么?(我已经删除了几乎所有代码来清除它)......
谢谢