scope of header files
Simon Marlow
simonmarhaskell at gmail.com
Tue Mar 11 19:25:52 EDT 2008
Duncan Coutts wrote:
> I was under the impression that with ghc, ffi import declarations like
> this do not escape the module:
>
> foreign import ccall unsafe "foo.h foo" foo :: IO ()
>
> However it seems that this one does:
>
> foreign import ccall unsafe "curses.h & stdscr" stdscrp :: Ptr WINDOWptr
>
> from:
> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mage-1.0
>
> perhapsPbecause it's a pointer import it gets treated differently?
I just tried this and couldn't reproduce the problem.
-----------------
module Test where
import Foreign
data WINDOWptr
foreign import ccall unsafe "curses.h & stdscr" stdscrp :: Ptr WINDOWptr
-----------------
Using -ddump-simpl we can see the declaration marked as NEVER inline,
and indeed it doesn't appear in the .hi file.
The code that does this is in DsForeign.csCImport, and it certainly
looks like it handles the &foo case in addition to normal foreign calls.
Maybe there's something else going on.. can you boil down the example at
all?
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list