On 08/11/12 22:52, Patrick wrote:
> I made all the changes you outlined but I don't fully understand what 
> the underlying issue was. Does the older version have trouble with type 
> casting with more current compilers?

        The newer compilers don't like it if you try to assign
        a 64bit pointer /directly/ into an int; it stops the build
        with a fatal "loss of precision" error.. g++ has no way to
        disable such errors AFAIK.

        We did this a lot because we use 'user_data' (which is a void*)
        to temporarily store all kinds of stuff, including ints.

        Our use is OK, because if we put a 32bit value into a 64bit pointer,
        then take it back out as a 32bit value, there's no loss.. but the 
compiler
        doesn't know that, and throws an error that can't be disabled.

> This is the offending line I am trying to resolve now in filename_list.cxx:
> 
> return scandir(d, list, 0, (int(*)(const void*,const void*))numericsort);
> 
> In the FLTK archives it mentioned changing the line to this:
> 
> return scandir(d, list, 0, (int(*)(void*,void*))numericsort);
> 
> but it did not seem to help.

        Let's look at the errors you pasted closely..
        I can't give you an absolute answer because I'm not having
        the problem here:

filename_list.cxx:56:74: error: invalid conversion from ‘int (*)(const void*, 
const void*)’ to ‘int (*)(const dirent**, const dirent**)’ [-fpermissive]

        The first part of the error says:

invalid conversion from ‘int (*)(const void*, const void*)’

        ..so that's what FLTK is passing the scandir function:
        a function pointer that returns an int and takes two arguments
        that are 'const void*'s.

        The error goes on to say:

to ‘int (*)(const dirent**, const dirent**)’

        ..which tells us what the scandir function is actually /expecting/
        a function pointer that returns an int and takes two arguments
        that are const dirent**'s.

        Function pointers are syntactically messy, but basically what has
        to happen here is you need to recast the func pointer from the former
        to the latter.

        The FLTK line in question currently reads:

return scandir(d, list, 0, (int(*)(const void*,const void*))numericsort);
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        The underlined bit is the problem, and is itself trying to
        re-cast the function pointer 'numericsort' from whatever it is
        to be a function that takes two const void*'s, but what the
        compiler /wants/ to see is two const dirent **'s.

        So I think if you just change the two instances of "const void*"
        in that line to const dirent**'s, that should fix it, I'd think.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to