Closed georgewsinger closed 5 years ago
I'm working with a C code base for which
typedef void(* wl_notify_func_t) (struct wl_listener *listener, void *data) //... struct wl_listener { struct wl_list link; wl_notify_func_t notify; //<-- I'd like to return this };
and have used the Haskell code
type NotifyFuncT = FunPtr (Ptr C'WlListener -> Ptr () -> IO ()) initializeMyCtx = C.context $ C.baseCtx <> C.funCtx <> mempty { C.ctxTypesTable = Data.Map.fromList [ (C.Struct "wl_listener", [t|C'WlListener|]) -- ... , (C.TypeName "wl_notify_func_t", [t|NotifyFuncT|]) ] } someHaskellFunction :: Ptr C'WlListener -> IO NotifyFuncT someHaskellFunction ptrToWlListener = do funPtr <- [C.block| wl_notify_func_t {return $(struct wl_listener * ptrToWlListener)->notify;}|] return funPtr
Unfortunately, I get an error from the inline-C code block which essentially says:
unexpected identifier wl_notify_func_t
So is what I'm doing even possible with inline-C?
This issue should be closed. The code above works; I just forgot to include the C context. :bowtie:
I'm working with a C code base for which
and have used the Haskell code
Unfortunately, I get an error from the inline-C code block which essentially says:
So is what I'm doing even possible with inline-C?