I would like to wrap a set of C functions with the following sig.:
ErrorCode Initialize(int *argc,char ***args, ...)
How is the double pointer represented in the FFI call? It is a pointer to a list of strings; is the following plausible?
foreign import ccall unsafe "lib.h Initialize"
c_initialize :: Ptr CInt
-> Ptr [String]
-> IO (Ptr CInt)
Or is the second argument a Ptr (Ptr Char)? I can't find this case in the literature I've read so far (Real World Haskell and the Wikibook) and my C is a bit rusty.
Thanks in advance
-- Correction :
RWH actually shows the interface to pcre_compile():
-- PCRE-compile.hs
foreign import ccall unsafe "pcre.h pcre_compile"
c_pcre_compile :: CString
-> PCREOption
-> Ptr CString
-> Ptr CInt
-> Ptr Word8
-> IO (Ptr PCRE)
Which corresponds to:
-- pcre.h
pcre *pcre_compile(const char *pattern,
int options,
const char **errptr,
int *errofset,
const unsigned char *tableptr);
Ptr (Ptr (Ptr CChar))since we have three*in front ofargs(andCCharis notChar).char***isPtr (Ptr (Ptr CChar)). As far as I know, there is no way to produce or consume aPtr [String](other than castPtr) because[String]is notStorable. So having your function take aPtr [String]would be pretty silly - you can never actually call it from Haskell, unless you have some other FFI function specifically for creating aPtr [String]for use with c_initialize.char *is usually aCString.