Pass custom data structures to C via Haskell FFI

Viewed 71

If I have a C function that looks like this

void print_addr(struct sockaddr_rc addr) {
    // some printing machinery
}

If I have defined a similar datastructure to struct sockaddr_rc in Haskell and implemented a Storable instance for it, is that enough to be able to define a foreign function like this?

foreign import ccall "print_addr" print_addr :: RFSocketAddress -> IO ()

I understood this to be the case, but I get an error telling me that there's an unacceptable argument in the foreign declaration, as RFSocketAddress can not be marshalled.

0 Answers
Related