Possible runtime overhead of wrapping the IO monad?
Brian Hulley
brianh at metamilk.com
Tue Mar 28 05:14:04 EST 2006
Simon Marlow wrote:
> Also the User's Guide has a snippet about it:
>
> http://www.haskell.org/ghc/docs/latest/html/users_guide/sec-ffi-ghc.html#glasgow-foreign-headers
>
> and this FAQ entry:
>
> http://haskell.org/haskellwiki/GHC/FAQ#When_I_use_a_foreign_function_that_takes_or_returns_a_float.2C_it_gives_the_wrong_answer.2C_or_crashes.
>
I've tried various command lines to try to get GHC to actually include the
header when compiling, but nothing seems to work, and I still get the error
message about implicit function declarations, for example when using:
C:\ghc\ghc-6.4\bin\ghc.exe -fglasgow-exts -fffi
-#include Duma.h --make main.hs -ddump-simpl
-O2 -fvia-C -optl-mwindows
-optl-lDuma -optl-L"c:\dll"
#ifdef __DUMA_H
#define __DUMA_H
#ifdef __cplusplus
extern "C" {
#endif
void duma_vertex3f(HsFloat x, HsFloat y, HsFloat z);
#ifdef __cplusplus
}
#endif
#endif // __DUMA_H
-- declared in Duma.hs
foreign import ccall "Duma.h" duma_vertex3f :: Float -> Float -> Float ->
IO ()
I've tried removing the "Duma.h" from the foreign import but that doesn't
help. Also, according to the FFI, for portability people are supposed to
always specify the header in the foreign import, so the fact that when you
do this, GHC disables cross module inlining is a real problem: you are
forced to write non-portable code.
Anyway all I'm interested in at the moment is trying to find a command line
which will cause GHC to compile everything using the header "Duma.h" so that
there will be no warning messages about implicit function declarations.
Is there anything else I could try?
Thanks, Brian.
More information about the Glasgow-haskell-users
mailing list