I have a little warning that I am trying to understand but it escapes
me. Perhaps someone can help here.
I have the function read_files() that scans the directory and return
the desired file names after filtering.
I have used the function file_select() to filter out unwanted files
and everything works nicely except that I keep getting the warning:
"warning: passing argument 3 of 'scandir' from incompatible pointer
type"
********
int read_files() {
/* Read directory and find desired files */
/* file_select is used to sort the files and fetch the desired files
*/
return scandir(DIR, &list, file_select, alphasort);
}
int file_select(struct direct *entry) {
if (strstr(entry->d_name,FILTER1) && strstr(entry->d_name,FILTER2)
&& strstr(entry->d_name,FILTER3)) {
return TRUE;
} else {
return FALSE;
}
}
Can someone enlighten me please!
/S
It seems to me that function's return type is wrong. I'm not sure what
should be return by 3rd parameter of scandir, but function returns
boolean value, while its return type is integer.
Regards,
Daniel
Declaration of scandir goes like this:
int scandir(const char *dir, struct dirent ***namelist,
int(*filter)(const struct dirent *),
int(*compar)(const struct dirent **, const struct dirent
**));
Note "const" modifier in filter's declaration. Change your file_select to:
int file_select(struct dirent const*)
JD