[Haskell-cafe] FFI question

Bulat Ziganshin bulatz at HotPOP.com
Thu Feb 9 05:24:42 EST 2006

Hello Frederico,

Thursday, February 09, 2006, 5:08:12 AM, you wrote:
FF> I'm developping a package wich imports C functions.

it depends on the details of your use. things go far away from the
times where FFI addendum was published, but there is no good
docementation, afaik.

first, there are a number of FFI-helper packages, that are directed to
simplify use of additional features, such as importimg constans,
enums, structures, i.e. things not in FFI standard

second, GHC nowadays can much easier use C functions. i personally do
the following:

ghc -c module.c
ghc --make main.hs module.o

and use module.h with usual declarations of function types while the main.hs
contains import staements like the

foreign import ccall unsafe "module.h __w_stat_ctime"   wst_ctime   :: Ptr CWStat -> IO CTime
foreign import ccall unsafe "module.h __w_stat_atime"   wst_atime   :: Ptr CWStat -> IO CTime

here< C functions __w_stat_ctime and __w_stat_ctime imported with
giving them in Haskell program names wst_ctime and wst_atime.

hope it will help. if not - give us additional details about your
usage of FFI.

Best regards,
 Bulat                            mailto:bulatz at HotPOP.com

More information about the Haskell-Cafe mailing list