blob: 24e9511d3be42a5419ed8099ac557cc9ed5c42ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
{-# LANGUAGE CPP #-}
module Main (main) where
#if defined(i386_HOST_ARCH)
# define WINDOWS_CCONV stdcall
#elif defined(x86_64_HOST_ARCH)
# define WINDOWS_CCONV ccall
#else
# error Unknown mingw32 arch
#endif
import Foreign.C.String (peekCWString)
import Foreign.C.Types (CWchar)
import Foreign.Marshal.Alloc (allocaBytes)
import Foreign.Ptr (Ptr)
foreign import WINDOWS_CCONV "hello" c_hello :: Ptr CWchar -> IO ()
main :: IO ()
main = allocaBytes 12 $ \buf -> do
c_hello buf
str <- peekCWString buf
putStrLn str
|