我对scandir()有疑问:联机帮助页包含此作为原型:
int scandir(const char *dir, struct dirent ***namelist,
int (*filter)(const struct dirent *),
int (*compar)(const struct dirent **, const struct dirent **));
因此我有这个:
static inline int
RubyCompare(const struct dirent **a,
const struct dirent **b)
{
return(strcmp((*a)->d_name, (*b)->d_name));
}
这是电话:
num = scandir(buf, &entries, NULL, RubyCompare);
最后编译器这样说:
warning: passing argument 4 of ‘scandir’ from incompatible pointer type
编译器是gcc-4.3.2,我的 CFLAGS 如下:
-Wall -Wpointer-arith -Wstrict-prototypes -Wunused -Wshadow -std=gnu99
这个警告的含义是什么?RubyCompare 的声明对我来说看起来是正确的,除了警告之外,代码完全可以工作。