Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE ScopedTypeVariables #-}
- module Main(main) where
- import System.Win32.DLL
- import System.Win32.Types as Win32Types
- import Foreign.Ptr
- import Foreign.C.String
- import Foreign.ForeignPtr
- foreign import ccall "dynamic"
- --c_TestInt :: FunPtr (Int -> IO (Int)) -> Int -> IO (Int)
- c_funcRetString :: FunPtr (IO (CString)) -> IO (CString)
- foreign import ccall "dynamic"
- c_funcInstantiate :: FunPtr (CString -> CString -> HMODULE -> IO (Ptr ())) -> CString -> CString -> HMODULE -> IO (Ptr ())
- dllNames = ["tank"]
- invokeFunction dll funcName funcType convType = do
- func <- getProcAddress dll funcName
- ret <- funcType $ castPtrToFunPtr func
- convType ret
- main :: IO ()
- main = do
- dll <- loadLibrary $ head dllNames
- invokeFunction dll "fmi2GetVersion" c_funcRetString peekCString >>= putStrLn . show
- invokeFunction dll "fmi2GetTypesPlatform" c_funcRetString peekCString >>= putStrLn . show
- instantiateFunc <- getProcAddress dll "fmi2Instantiate"
- t1 <- withCString "t1"
- t2 <- withCString "t2"
- instantiateRet <- c_funcInstantiate (castPtrToFunPtr instantiateFunc) t1 t2 dll
- putStrLn . show $ 1
- C:\source\speciale\r_and_d\source\hs_prototype\dynamic_loading_tank_tankcontroller\main.hs:29:9-24: Couldn't match expected type `IO CString' …
- with actual type `(CString -> IO a0) -> IO a0'
- Probable cause: `withCString' is applied to too few arguments
- In a stmt of a 'do' block: t1 <- withCString "t1"
- In the expression:
- do { dll <- loadLibrary $ head dllNames;
- invokeFunction dll "fmi2GetVersion" c_funcRetString peekCString
- >>= putStrLn . show;
- invokeFunction
- dll "fmi2GetTypesPlatform" c_funcRetString peekCString
- >>= putStrLn . show;
- instantiateFunc <- getProcAddress dll "fmi2Instantiate";
- .... }
- C:\source\speciale\r_and_d\source\hs_prototype\dynamic_loading_tank_tankcontroller\main.hs:30:9-24: Couldn't match expected type `IO CString' …
- with actual type `(CString -> IO a1) -> IO a1'
- Probable cause: `withCString' is applied to too few arguments
- In a stmt of a 'do' block: t2 <- withCString "t2"
- In the expression:
- do { dll <- loadLibrary $ head dllNames;
- invokeFunction dll "fmi2GetVersion" c_funcRetString peekCString
- >>= putStrLn . show;
- invokeFunction
- dll "fmi2GetTypesPlatform" c_funcRetString peekCString
- >>= putStrLn . show;
- instantiateFunc <- getProcAddress dll "fmi2Instantiate";
- .... }
- Compilation failed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement