int setmodulestring(char* parameter, int parameterLength, char* value, int valueLength, int setVarInArray);In ghci the main and setmodulestring functions works fine
This does not seems correct (or incomplete).On 03/14/2014 11:24 PM, Miroslav Karpis wrote:
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 probably
If 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
segfaults) I cannot say anything further.
exact ffi declaration of c_setmodulestring would be usefull, too,
to compare with C function.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe