J'ai un problème avec scandir(): La page de manuel contient ce que prototype:prototype Manpage scandir() de bizarreries
int scandir(const char *dir, struct dirent ***namelist,
int (*filter)(const struct dirent *),
int (*compar)(const struct dirent **, const struct dirent **));
J'ai donc ceci:
static inline int
RubyCompare(const struct dirent **a,
const struct dirent **b)
{
return(strcmp((*a)->d_name, (*b)->d_name));
}
Et voici l'appel :
num = scandir(buf, &entries, NULL, RubyCompare);
Enfin le compilateur dit ceci:
warning: passing argument 4 of ‘scandir’ from incompatible pointer type
compilateur est gcc-4.3.2, mes CFLAGS suivent:
-Wall -Wpointer-arith -Wstrict-prototypes -Wunused -Wshadow -std=gnu99
Quelle est la signification de cet avertissement? La déclaration de RubyCompare me semble correcte et en plus de l'avertissement le code fonctionne complètement.
bien droit, j'ai écrit ma propre version parce que la manpage était trompeur avec la portabilité d'alphasort() aussi bien. Avec alphasort() ça marche, marrant que je ne l'ai jamais essayé. ;) – unexist
Cela me donne un avertissement car il est en train de supprimer le qualificatif const des arguments void. Y a-t-il un moyen de contourner ceci? – TartanLlama
@TartanLiama: Je ne sais pas comment vous obtenez cet avertissement, je ne peux pas le reproduire. Il ne modifie pas * a ou * b. – Chris