Pragmas for FFI imports
John Meacham
john at repetae.net
Mon Feb 20 22:59:37 EST 2006
On Fri, Feb 17, 2006 at 01:45:27AM +0200, Einar Karttunen wrote:
> I would like to propose two pragmas to be included in Haskell'
> for use with FFI. One for specifying the include file defining
> the foreign import (INCLUDE in ghc) and an another for defining
> a library that the foreign import depends on, called FFI_LIB
> (not implemented at the moment). These changes would not break
> any existing code.
Just to expand on this, Einar is working on adding this support to jhc
right now in his work on the library system in jhc. the semantic we
decided on was that an
{-# INCLUDE "foo.h" #-}
in any module will have the equivalent effect of adding an include to
each foreign ccall in the current module like so:
foreign import ccall "foo.h foo" foo :: Int -> Int
I say equivalent effect because I know ghc treats includes somewhat
differently depending on where they are specified but the eventual
user visible effect is the same (I think, if I understand things)
the same will be true of the FFI_LIB flag,
{-# FFI_LIB libm #-}
foreign import ccall "-lm foo.h foo" foo :: Int -> Int
(note: jhc non-standard syntax extension here)
John
--
John Meacham - ⑆repetae.net⑆john⑈
More information about the Haskell-prime
mailing list