This does not seems correct (or incomplete).Hi, please can you help me with following?
I have a call to an external dll (via ffi) which if executed from ghci works fine.If I compile my code with 'ghc -o fm Mycode.hs -L. -lextdll' and run it I get 'Segmentation fault/access violation in generated code'.
main = dolet param = "FilePath"let value = "C:/dev/misc/haskell/services/FM"result <- liftIO $ FM.setmodulestring param valuereturn "done"
setmodulestring :: String -> String -> IO CIntsetmodulestring param value = dolet cParamLength = fromIntegral $ length param ::CIntcValueLength = fromIntegral $ length value ::CIntsetVarInArray = (-1)::CIntalloca $ \cParam -> doalloca $ \cValue -> doresult <- c_setmodulestring cParam cParamLength cValue cValueLength setVarInArrayreturn result
This one may be correct but without, seeing C code (where it probablyIf I try also with following, the behaviour is the same:
setmodulestring2 :: String -> String -> IO CIntsetmodulestring2 param value = docParam <- newCWString paramcValue <- newCWString valuelet cParamLength = fromIntegral $ length param ::CIntcValueLength = fromIntegral $ length value ::CIntsetVarInArray = (-1)::CIntresult <- c_setmodulestring cParam cParamLength cValue cValueLength setVarInArrayfree cParamfree cValuereturn res