On Fri, Sep 20, 2013 at 6:53 PM, Miro Karpis <miroslav.karpis@gmail.com> wrote:
Please, I just can not figure this out:

I have a method in my C dll:
int somemethod(char *param, int length, double array[], int UB1, int UB2, bool isValid);

I would like to use this method in Haskell, so I have defined it like:

foreign import stdcall unsafe "somemethod"  c_somemethod :: Ptr CString 

You don't want Ptr CString.  See:

    Prelude> :m +Foreign.C.String
    Prelude Foreign.C.String> :i CString
    type CString = GHC.Ptr.Ptr Foreign.C.Types.CChar
  -- Defined in `Foreign.C.String'

In other words, CString is an alias for Ptr CChar. Ptr CString corresponds to (char **), not (char *).

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net