sys/dir.h

The prototype of scandir is:

extern int scandir(char *__dirname, struct direct *(*namelist[]),
int (*select)(), int (*compar)());

The argument to select and compare are not declared, this doesn’t
work in C++. Nor is very safe in C.

  • Mario

I’ve added a PR for this.

Mario Charest <mcz@videotron.ca> wrote:


The prototype of scandir is:

extern int scandir(char *__dirname, struct direct *(*namelist[]),
int (*select)(), int (*compar)());

The argument to select and compare are not declared, this doesn’t
work in C++. Nor is very safe in C.

“Colin Burgess” <cburgess@qnx.com> wrote in message
news:8rl81c$mhp$1@nntp.qnx.com

I’ve added a PR for this.

Mario Charest <> mcz@videotron.ca> > wrote:


The prototype of scandir is:

extern int scandir(char *__dirname, struct direct *(*namelist[]),
int (*select)(), int (*compar)());

Actually it looks like if a select function is provided it get’s passed
and invalide argument ( points to garbage ). Thanks for the PR.
Still haven’t go use to the “anonymous/no feedback” qdn PR web page :wink:


The argument to select and compare are not declared, this doesn’t
work in C++. Nor is very safe in C.

Ugh, you’re probably getting bitten by the
fact that the select function takes a struct dirent * parameter,
while the compare takes two struct direct ** parameters.

Don’t ask me why…

Mario Charest <mcz@videotron.ca> wrote:

“Colin Burgess” <> cburgess@qnx.com> > wrote in message
news:8rl81c$mhp$> 1@nntp.qnx.com> …
I’ve added a PR for this.

Mario Charest <> mcz@videotron.ca> > wrote:


The prototype of scandir is:

extern int scandir(char *__dirname, struct direct *(*namelist[]),
int (*select)(), int (*compar)());


Actually it looks like if a select function is provided it get’s passed
and invalide argument ( points to garbage ). Thanks for the PR.
Still haven’t go use to the “anonymous/no feedback” qdn PR web page > :wink:



The argument to select and compare are not declared, this doesn’t
work in C++. Nor is very safe in C.


cburgess@qnx.com

“Colin Burgess” <cburgess@qnx.com> wrote in message
news:8rq90u$4mc$1@nntp.qnx.com

Ugh, you’re probably getting bitten by the
fact that the select function takes a struct dirent * parameter,
while the compare takes two struct direct ** parameters.

Don’t ask me why…

I used “struct direct *” ;-(

Mario Charest <> mcz@videotron.ca> > wrote:

“Colin Burgess” <> cburgess@qnx.com> > wrote in message
news:8rl81c$mhp$> 1@nntp.qnx.com> …
I’ve added a PR for this.

Mario Charest <> mcz@videotron.ca> > wrote:


The prototype of scandir is:

extern int scandir(char *__dirname, struct direct *(*namelist[]),
int (*select)(), int (*compar)());


Actually it looks like if a select function is provided it get’s passed
and invalide argument ( points to garbage ). Thanks for the PR.
Still haven’t go use to the “anonymous/no feedback” qdn PR web page > :wink:


The argument to select and compare are not declared, this doesn’t
work in C++. Nor is very safe in C.

Mario Charest <mcz@videotron.ca> wrote:

“Colin Burgess” <> cburgess@qnx.com> > wrote in message
news:8rq90u$4mc$> 1@nntp.qnx.com> …
Ugh, you’re probably getting bitten by the
fact that the select function takes a struct dirent * parameter,
while the compare takes two struct direct ** parameters.

Don’t ask me why…


I used “struct direct *” ;-(

Alright, hands up how many people would be really pissed if I changed
scandir to use struct dirent * for both functions? (this would
match netbsd and linux, but mismatch Solaris).

“Colin Burgess” <> cburgess@qnx.com> > wrote in message
news:8rl81c$mhp$> 1@nntp.qnx.com> …
I’ve added a PR for this.

Mario Charest <> mcz@videotron.ca> > wrote:


The prototype of scandir is:

extern int scandir(char *__dirname, struct direct *(*namelist[]),
int (*select)(), int (*compar)());


Actually it looks like if a select function is provided it get’s passed
and invalide argument ( points to garbage ). Thanks for the PR.
Still haven’t go use to the “anonymous/no feedback” qdn PR web page > :wink:


The argument to select and compare are not declared, this doesn’t
work in C++. Nor is very safe in C.


cburgess@qnx.com

I used “struct direct *” ;-(

Alright, hands up how many people would be really pissed if I changed
scandir to use struct dirent * for both functions? (this would
match netbsd and linux, but mismatch Solaris).

I wouldn’t mind as long as the prototypes are present!!!

  • Mario

Mario Charest <mcz@videotron.ca> wrote:

I used “struct direct *” ;-(

Alright, hands up how many people would be really pissed if I changed
scandir to use struct dirent * for both functions? (this would
match netbsd and linux, but mismatch Solaris).


I wouldn’t mind as long as the prototypes are present!!!

Unforunately this would make the libc incompatible with the existing
one. I think we will have to wait until the new Dinkum libc to think
about this…

In the meantime I will ask the docs people to document it as is…


cburgess@qnx.com