
Hi, I am trying to generalize my knowledge about FFI declarations when dealing with pointers to pointers (import from C to Haskell). Maybe these are silly questions, but It seems to me, I am missing some understanding. Per the FFI Addendum: For a variable, we use "&" import: int bar; foreign import ccall "&" bar :: Ptr CInt If we have int *pbar;, will Ptr (Ptr CInt) be correct? For arbitrary level of pointer nesting, will nesting of the same number of Ptr's be correct? For a function, we use "static" import: int system (char *str); foreign import ccall "static stdlib.h" system :: Ptr CChar -> IO CInt but for a pointer to a function (i. e. a variable) we use: int (*psystem) (char *str); foreign import ccall "dynamic" mkFun :: FunPtr (CInt -> IO ()) -> (CInt -> IO ()) and then psystem should be declared as a variable with "&" import, I believe. Or as a FunPtr? And then (mkFun psystem) returns something to be called as a function. Then (talking to myself) pointer to pointer to a function may be imported as shown in the very beginning, i. e. by nesting Ptr's? So indeed my question is: would nesting of Ptr's work if nested pointers are imported? I haven't experimented with this yet, but maybe someone has? Thanks for any advice. -- Dimitry Golubovsky Anywhere on the Web
participants (1)
-
Dimitry Golubovsky