Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - missing const qualifiers in scandir() declaration in <dirent.h>: (2 Items)
   
missing const qualifiers in scandir() declaration in <dirent.h>  
Dear all,

I have found, that header <dirent.h> contains scandir() declaration without const qualifier for the first argument.

extern int      scandir(char *__dirname, struct dirent ***__namelist,
                        int (*__select)(const struct dirent *),
                        int (*__compar)(const void *,const void *));

According to POSIX:2008 standard (http://www.opengroup.org/onlinepubs/9699919799/functions/scandir.html, I do not know 
how about the others) there should be const qualifier for the first argument.

In fact, the QNX libc source code (lib/c/unix/scandir.c) declares const for all the parameters.

I have found this issue while porting some C++ code to QNX, because of call:
scandir(string.c_str(), ...);
Of course I can do a cast to (char *), but it is not nice solution.

Do you think that this can be somehow solved in QNX headers?

Best regards,
Re: missing const qualifiers in scandir() declaration in <dirent.h>  
On Sun, 2010-05-16 at 05:12 -0400, Piotr Trojanek wrote:
> I have found, that header <dirent.h> contains scandir() declaration without const qualifier for the first argument.

scandir() was only introduced with version 7 (i.e. 2008) and we are
currently certified against earlier versions (most recently, I think,
PSE52 2003).  Prior to this, it is supported as a miscellaneous Unix
extension.

I've raised PR76860 for this issue.  I can't say with any certainty how
or when this will be addressed as it may get tangled up in the broader
issue of 2008 compliance. Apologies for the inconvenience.

> In fact, the QNX libc source code (lib/c/unix/scandir.c) declares const for all the parameters.

Keep in mind that "char * const" does not mean the same thing as "const
char *" :-)

Regards,
Neil