
2009/11/10 Philippos Apolinarius
I don't know how to mark the call unsafe. [...] I am running the main program on Windows.
Marking it unsafe is done by putting "unsafe" in the foreign import declaration. Even if it turns out not to fix the problem, it reduces the overhead of foreign calls (and is safe as long as they aren't going to call back into Haskell). Because your on Windows, you want to use "stdcall", as mentioned by Daniel Fischer. Thus the full declaration is: foreign import stdcall unsafe "rs232.h closecport" closecport :: IO () Let us know if this helps.
Here is the compilation script:
ghc -fglasgow-exts serial.c %1.hs -L./ -ljapi --make erase *.hi erase *.o strip %1.exe
I encourage you to look into Cabal soon :) -- Jason Dusek