[commit: packages/Win32] master: [ghc trac #10165] Conditionally call SetWindowLongW on mingw32 (9e52103)

git at git.haskell.org git at git.haskell.org
Thu Jul 30 06:57:59 UTC 2015


Repository : ssh://git@git.haskell.org/Win32

On branch  : master
Link       : http://git.haskell.org/packages/Win32.git/commitdiff/9e52103b8b4a9bfb486e2289257ec61ac682eb89

>---------------------------------------------------------------

commit 9e52103b8b4a9bfb486e2289257ec61ac682eb89
Author: Vagrant Ubuntu 14.04 Trusty 64-bit VMware <dedgrant at gmail.com>
Date:   Tue Mar 17 16:21:02 2015 -0700

    [ghc trac #10165] Conditionally call SetWindowLongW on mingw32


>---------------------------------------------------------------

9e52103b8b4a9bfb486e2289257ec61ac682eb89
 Graphics/Win32/Window.hsc | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/Graphics/Win32/Window.hsc b/Graphics/Win32/Window.hsc
index 81baf3d..e5bd152 100644
--- a/Graphics/Win32/Window.hsc
+++ b/Graphics/Win32/Window.hsc
@@ -204,7 +204,24 @@ setWindowClosure wnd closure = do
   _ <- c_SetWindowLongPtr wnd (#{const GWLP_USERDATA})
                               (castPtr (castFunPtrToPtr fp))
   return ()
+
+{- Note [SetWindowLongPtrW]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Windows.h defines SetWindowLongPtrW as SetWindowLongW for 32-bit platforms
+(i386_HOST_ARCH for our mingw32 environment). Unfortunately since the foreign
+import name is given inside of a string, the macro will not be expanded.
+
+Until a better solution is presented each version is provided explicitly here.
+
+-}
+#if defined(i386_HOST_ARCH)
+foreign import WINDOWS_CCONV unsafe "windows.h SetWindowLongW"
+#elif defined(x86_64_HOST_ARCH)
 foreign import WINDOWS_CCONV unsafe "windows.h SetWindowLongPtrW"
+#else
+# error Unknown mingw32 arch
+#endif
   c_SetWindowLongPtr :: HWND -> INT -> Ptr LONG -> IO (Ptr LONG)
 
 createWindow



More information about the ghc-commits mailing list