This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

POSIX.1 and scandir


I got this. What does POSIX.1 say on this?



H.J.
---
So I'm trying to worm all of the warnings out of gnulpr, and I keep
getting type mismatch errors on parameter 4 of scandir().

Looking at the manpage, I see:

SYNOPSIS
       #include <dirent.h>

       int scandir(const char *dir, struct dirent ***namelist,
              int (*select)(const struct dirent *),
              int (*compar)(const struct dirent *, const struct dirent *));

...and that's the way our compar function is written.

Everything looks good, so I check out what the compiler sees -- the
headers.  And in /usr/include/dirent.h, we see:

extern int scandir (__const char *__restrict __dir,
                    struct dirent ***__restrict __namelist,
                    int (*__selector) (__const struct dirent *),
                    int (*__cmp) (__const void *, __const void *)) __THROW;

	So the man page says struct dirent *, and the headers say void
* (yet only for the comparator, and not the selector, for some
reason).  The logical arbiter in this situation would be POSIX.  But
I'm in the office today and my POSIX book is at home, so today I
learned that POSIX.1 is a paper-only document.  I thought for sure
there was a bug in google.

	So can someone who has a POSIX document or the O'Reilly
rundown tell me what the proper parameter types are for the comparator
function?  This is driving me batty.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]