Don't use stdcall on Win64: It isn't supported; ccall is used instead
[hsc2hs.git] / Main.hs
diff --git a/Main.hs b/Main.hs
index 689997b..9838141 100644 (file)
--- a/Main.hs
+++ b/Main.hs
@@ -40,6 +40,16 @@ import DirectCodegen
 import Flags
 import HSCParser
 
+#ifdef mingw32_HOST_OS
+# 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
+#endif
+
 #ifdef BUILD_NHC
 getDataFileName s = do here <- getCurrentDirectory
                        return (here++"/"++s)
@@ -222,7 +232,7 @@ getExecPath = try_size 2048 -- plenty, PATH_MAX is 512 under Win32.
           _ | ret < size -> fmap Just $ peekCWString buf
             | otherwise  -> try_size (size * 2)
 
-foreign import stdcall unsafe "windows.h GetModuleFileNameW"
+foreign import WINDOWS_CCONV unsafe "windows.h GetModuleFileNameW"
   c_GetModuleFileName :: Ptr () -> CWString -> Word32 -> IO Word32
 #else
 getExecPath = return Nothing