I have some questions about the FFI in Haskell
{-# LANGUAGE ForeignFunctionInterface #-} but what is the difference when i use {-# LANGUAGE CPP, ForeignFunctionInterface #-} what can i do "more" with the CPPstruct, how can i handle this in the FFI?CInt and when just Int?CPP language extension, you can then legally encorporate C pre-processor syntax into your Haskell program.Storable typeclass to define peek and poke methods for each field of the struct. The hsc2hs tool can help.CInt whenever you need to pass a Haskell Int to or from C, as this will ensure any required marshalling takes place (same goes for CDouble, CString and so on).The X11 package has many examples of defining and marshalling structs via the FFI.
More info in:
CPP is the C preprocessor. It allows you to use conditional compilation and makros. Usually, you don't need this, but it becomes useful, as soon as you have platform-dependent code, where the code to compile is decided by an external script (like with the autotools).Cint only for the direct import. When writing a high-level binding, switch to Int as it doesn't requires the user to import the required libraries and is Haskell standardIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With