Ich habe ein Problem mit scandir(): Die Manpage enthält das als Prototyp:Manpage scandir() Prototyp Seltsamkeit
int scandir(const char *dir, struct dirent ***namelist,
int (*filter)(const struct dirent *),
int (*compar)(const struct dirent **, const struct dirent **));
Deshalb habe ich dies:
static inline int
RubyCompare(const struct dirent **a,
const struct dirent **b)
{
return(strcmp((*a)->d_name, (*b)->d_name));
}
Und hier ist der Aufruf :
num = scandir(buf, &entries, NULL, RubyCompare);
Schließlich sagt der Compiler dies:
warning: passing argument 4 of ‘scandir’ from incompatible pointer type
Compiler ist gcc-4.3.2, mein CFLAGS sind wie folgt:
-Wall -Wpointer-arith -Wstrict-prototypes -Wunused -Wshadow -std=gnu99
Was ist die Bedeutung dieser Warnung? Die Deklaration von RubyCompare sieht für mich korrekt aus und neben der Warnung funktioniert der Code vollständig.
Nun gut, schrieb ich meine eigene Version, weil die Die Manpage war mit der Portabilität von alphasort() ebenfalls irreführend. Mit alphasort() funktioniert es, komisch, dass ich es nie ausprobiert habe. ;) – unexist
Dies führt zu einer Warnung, weil das const-Qualifikationsmerkmal aus den void-Argumenten entfernt wird. Gibt es einen Weg dahin? – TartanLlama
@TartanLiama: Ich weiß nicht, wie Sie diese Warnung bekommen, ich kann es nicht reproduzieren. Es ändert nicht * a oder * b. – Chris