--- Gracjan Polak <[EMAIL PROTECTED]> wrote: > foreign import stdcall "windows.h &UnmapViewOfFile" > funptrUnmapViewOfFile :: FunPtr (Ptr > a -> IO ()) > > > Basically I'd love to do (in Windows world): > > mapTheFileToMemory = do > handle <- winOpenFile(...) > mapping <- winCreateFileMapping(...) > view <- winMapViewOfFile(...) > finview <- newForeignPtr funptrUnmapViewOfFile > view > return finview > > Strangely enough my finalizer run always this time, > no need to say > performGC or yield'ing at the end of main. But it > crashes my program :(
The problem here is that the external functions (instances of type FunPtr) are always executed with ccall convention regardless of stdcall declaration in the foreign import. The workaround is to write simple stub function in C with ccall convention. > > Warnings in compilation are also strange: > > $ ghc -package win32 --make interlvIO.hs -o > interlvIO.exe > Chasing modules from: interlvIO.hs > Compiling Main ( interlvIO.hs, > interlvIO.o ) > Linking ... > Warning: resolving _UnmapViewOfFile by linking to > [EMAIL PROTECTED] > Use --enable-stdcall-fixup to disable these warnings > Use --disable-stdcall-fixup to disable these fixups Try to use -fvia-C to avoid the warnings. When the program is compiled via the native code generator then windows.h isn't included and this causes the problem. __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ _______________________________________________ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users