Profiling makes FFI Marshalling of Doubles and Int64s fail
Simon Marlow
simonmar at microsoft.com
Wed Sep 15 05:23:38 EDT 2004
On 15 September 2004 00:33, Roberto Zunino wrote:
> However, compiling with
>
> ghc -prof Main.hs test.c -#include test.h
>
> or s/-prof/-fvia-C/, works fine, provided test.h contains the correct
> function prototypes.
>
> ------ test.h
> long long myInt64(void);
> double myDouble(void);
> ------
>
> AFAICS, it seems as the asm code generator knows about the Haskell
> types and therefore knows how to fetch the bits correctly, while the
> via-C code generator simply uses the C function calls (without
> prototypes), so functions return types are defaulted to int.
>
> Also, you can try adding -Wall and see if the C compiler warns about
> this (mine does).
>
> The GHC user's guide (section 8.2.2) is also insightful. It seems that
> using C headers is pretty much required, or, as the guide itself says,
> "You're crazy not to do it". ;-)
This is correct. You should get a warning from the C compiler even
without -Wall, because we turn on -Wimplicit to catch exactly these
problems.
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list