Ian MacArthur wrote: > Michael Baeuerle wrote: > > > > At the moment I can't access the Sun machine from here, but I have > > tested on AIX 5.1 and HP-UX 11.11 and it works on both. I will test on > > the Sun the next few days. In the meanwhile it would be nice if somebody > > else can run the test programs on other systems. > > Tried it on a few linux distros, and on OSX (10.6.8) > > Appears to be good. > > Observations are... > > - Had to add #include <string.h> into scandir_old.c to get things to > compile nicely (on linux and OSX)
Yes, my fault. I have ripped out the original FLTK preprocessor stuff (because my demo don't use autoconf) and forget to insert '#include <string.h>' instead. > - Added -Wall to the Makefile, just in case, but it didn't flag much > of note, other than... Some commercial compilers (like the SunPro) don't understand "-Wall", therefore I have left it out for the demo. > - The "native" test on OSX fails outright, the OSX scandir is > "odd"... And forcibly setting > > #define _POSIX_C_SOURCE 200809L > > makes it worse... Commenting out that line allows the code to run > "correctly" but -Wall warns that the prototype is wrong > (unsurprisingly!) AFAIK MacOS X has a BSD based userland. I have seen the same thing while testing on NetBSD, there are two native 'scandir()' implementations in libc and only one works (but both hasn't POSIX compliant parameter declarations). The problem here is that we requested something that in fact the system don't claim to provide. I have modfied the Makefile so that the native test is only build if the system claims to be POSIX.1-2008 compliant. Recent GNU/Linux distributions do that. The feature request in 'scandir_new.c' was also wrong and give warnings on SunOS with threads enabled. I have corrected it and now it runs cleanly on SunOS too (with and without threads). BTW: Oracle has some documentation of the values for older standards: http://docs.oracle.com/cd/E19963-01/html/821-1474/standards-5.html Finally I have run the new implementation on Valgrind and found no further errors. http://micha.freeshell.org/tmp/2013-02-18_scandir.tar.gz To include the new code into FLTK I would consider the following things: 1) Import new code to 'src/scandir.c' 2) Change function name from 'scandir_new()' to 'fl_scandir()' 3) '#include "../config.h"' at the beginning so that 'HAVE_PTHREAD' from autoconf becomes visible. The feature test macros must stay before the first '#include' of a system header file to work correctly 4) Ensure that 'src/scandir.c' is not build with a C++ compiler (Looks like this is already the case) 5) List the FLTK license text in the header instead of hyperlink 6) Change the switching code in 'src/filename_list.cxx' like this: ---------------------------------------------------------------------- extern "C" { #ifndef HAVE_SCANDIR int fl_scandir (const char *dir, dirent ***namelist, int (*select)(dirent *), int (*compar)(dirent **, dirent **)); #endif } ... #ifndef HAVE_SCANDIR // This version is when we define our own scandir int n = fl_scandir(dirloc, list, 0, sort); ---------------------------------------------------------------------- should become something like this: ---------------------------------------------------------------------- extern "C" { #ifndef HAVE_SCANDIR int fl_scandir (const char *dir, struct dirent ***namelist, int (*sel)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **)); #endif } ... #ifndef HAVE_SCANDIR // This version is when we define our own scandir int n = fl_scandir(dirloc, list, 0, (int(*)(const struct dirent **, const struct dirent **)) sort); ---------------------------------------------------------------------- Regards, Micha _______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

