> > | The ``foreign import'' bug for Float types is still present 
> > | in ghc-4.08.
> > 
> > This bug is definitely present in the native code route.
> > 
> > It would be good to know if the bug exists on the via-C route.
> > If you recompile with -fvia-C (perhaps check with -v to be sure
> > it really does go via C), does the problem still exist?  
> 
> Yes, -fvia-C using the released 4.08 displays exactly the same bug.

Going via C is fine, as long as you -#include the relevant prototype for the
C function you're calling.  Otherwise the C compiler automatically promotes
the arguments/result to doubles and you're hosed.

There's been a great deal of discussion on the FFI list (as I'm sure you've
seen) about how to do this properly.  We can't just generate a prototype
inline, because it might conflict with a prototype that's already in scope.
Solutions have been proposed, but none have been settled on as yet.

Ironically, the NCG now works better than compiling via C because it doesn't
suffer from this problem (but it also doesn't check that the type you gave
for the foreign import matches the actual type of the C function you're
calling).

Cheers,
        Simon

Reply via email to