I've built a small test case. When I compile with: ghc Main.hs test.c -o Main.exe
... the (correct) output from Main.exe is: 123.0 5678901234567890
And when I compile with: ghc -prof Main.hs test.c -o Main.exe
... the (incorrect) output from Main.exe is: 1.0 986516178
I don't know if this helps, but I want to share it anyway.
I made some tests and saw that compiling with -fvia-C also gives the (incorrect) 986516178, while -fasm yields the expected value. I am using Linux/x86 here, so YMMV.
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". ;-)
Regards, Roberto Zunino.
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users