Permalink
Browse files

Fix warnings on Win64

Mostly this meant using UINT_PTR instead of UINT.
  • Loading branch information...
1 parent 690c205 commit f7131474d172332f3469775af326b264fabafab8 @igfoo igfoo committed Apr 24, 2012
@@ -43,7 +43,7 @@ mkDialogTemplate = newTString
type ResourceID = Int
mkResource :: ResourceID -> IO (Ptr a)
-mkResource res = return (castUINTToPtr (fromIntegral res))
+mkResource res = return (castUINTPtrToPtr (fromIntegral res))
mkDialogTemplateFromResource :: Int -> IO DTemplate
mkDialogTemplateFromResource = mkResource
@@ -215,11 +215,11 @@ type MbHDWP = Maybe HDWP
type HWND = HANDLE
type MbHWND = Maybe HWND
-#{enum HWND, castUINTToPtr
- , hWND_BOTTOM = HWND_BOTTOM
- , hWND_NOTOPMOST = HWND_NOTOPMOST
- , hWND_TOP = HWND_TOP
- , hWND_TOPMOST = HWND_TOPMOST
+#{enum HWND, castUINTPtrToPtr
+ , hWND_BOTTOM = (UINT_PTR)HWND_BOTTOM
+ , hWND_NOTOPMOST = (UINT_PTR)HWND_NOTOPMOST
+ , hWND_TOP = (UINT_PTR)HWND_TOP
+ , hWND_TOPMOST = (UINT_PTR)HWND_TOPMOST
}
type HMENU = HANDLE
@@ -24,7 +24,6 @@ import Data.Maybe
import Foreign
#include <windows.h>
-#include "gettime.h"
----------------------------------------------------------------
-- Resources
@@ -63,24 +62,24 @@ loadIcon mb_inst icon =
foreign import stdcall unsafe "windows.h LoadIconW"
c_LoadIcon :: HINSTANCE -> Icon -> IO HICON
-#{enum Cursor, castUINTToPtr
- , iDC_ARROW = (UINT)IDC_ARROW
- , iDC_IBEAM = (UINT)IDC_IBEAM
- , iDC_WAIT = (UINT)IDC_WAIT
- , iDC_CROSS = (UINT)IDC_CROSS
- , iDC_UPARROW = (UINT)IDC_UPARROW
- , iDC_SIZENWSE = (UINT)IDC_SIZENWSE
- , iDC_SIZENESW = (UINT)IDC_SIZENESW
- , iDC_SIZEWE = (UINT)IDC_SIZEWE
- , iDC_SIZENS = (UINT)IDC_SIZENS
+#{enum Cursor, castUINTPtrToPtr
+ , iDC_ARROW = (UINT_PTR)IDC_ARROW
+ , iDC_IBEAM = (UINT_PTR)IDC_IBEAM
+ , iDC_WAIT = (UINT_PTR)IDC_WAIT
+ , iDC_CROSS = (UINT_PTR)IDC_CROSS
+ , iDC_UPARROW = (UINT_PTR)IDC_UPARROW
+ , iDC_SIZENWSE = (UINT_PTR)IDC_SIZENWSE
+ , iDC_SIZENESW = (UINT_PTR)IDC_SIZENESW
+ , iDC_SIZEWE = (UINT_PTR)IDC_SIZEWE
+ , iDC_SIZENS = (UINT_PTR)IDC_SIZENS
}
-#{enum Icon, castUINTToPtr
- , iDI_APPLICATION = (UINT)IDI_APPLICATION
- , iDI_HAND = (UINT)IDI_HAND
- , iDI_QUESTION = (UINT)IDI_QUESTION
- , iDI_EXCLAMATION = (UINT)IDI_EXCLAMATION
- , iDI_ASTERISK = (UINT)IDI_ASTERISK
+#{enum Icon, castUINTPtrToPtr
+ , iDI_APPLICATION = (UINT_PTR)IDI_APPLICATION
+ , iDI_HAND = (UINT_PTR)IDI_HAND
+ , iDI_QUESTION = (UINT_PTR)IDI_QUESTION
+ , iDI_EXCLAMATION = (UINT_PTR)IDI_EXCLAMATION
+ , iDI_ASTERISK = (UINT_PTR)IDI_ASTERISK
}
----------------------------------------------------------------
@@ -56,24 +56,24 @@ foreign import stdcall unsafe "windows.h EndUpdateResourceW"
type ResourceType = LPCTSTR
-#{enum ResourceType, castUINTToPtr
- , rT_ACCELERATOR = (UINT)RT_ACCELERATOR // Accelerator table
- , rT_ANICURSOR = (UINT)RT_ANICURSOR // Animated cursor
- , rT_ANIICON = (UINT)RT_ANIICON // Animated icon
- , rT_BITMAP = (UINT)RT_BITMAP // Bitmap resource
- , rT_CURSOR = (UINT)RT_CURSOR // Hardware-dependent cursor resource
- , rT_DIALOG = (UINT)RT_DIALOG // Dialog box
- , rT_FONT = (UINT)RT_FONT // Font resource
- , rT_FONTDIR = (UINT)RT_FONTDIR // Font directory resource
- , rT_GROUP_CURSOR = (UINT)RT_GROUP_CURSOR // Hardware-independent cursor resource
- , rT_GROUP_ICON = (UINT)RT_GROUP_ICON // Hardware-independent icon resource
- , rT_HTML = (UINT)RT_HTML // HTML document
- , rT_ICON = (UINT)RT_ICON // Hardware-dependent icon resource
- , rT_MENU = (UINT)RT_MENU // Menu resource
- , rT_MESSAGETABLE = (UINT)RT_MESSAGETABLE // Message-table entry
- , rT_RCDATA = (UINT)RT_RCDATA // Application-defined resource (raw data)
- , rT_STRING = (UINT)RT_STRING // String-table entry
- , rT_VERSION = (UINT)RT_VERSION // Version resource
+#{enum ResourceType, castUINTPtrToPtr
+ , rT_ACCELERATOR = (UINT_PTR)RT_ACCELERATOR // Accelerator table
+ , rT_ANICURSOR = (UINT_PTR)RT_ANICURSOR // Animated cursor
+ , rT_ANIICON = (UINT_PTR)RT_ANIICON // Animated icon
+ , rT_BITMAP = (UINT_PTR)RT_BITMAP // Bitmap resource
+ , rT_CURSOR = (UINT_PTR)RT_CURSOR // Hardware-dependent cursor resource
+ , rT_DIALOG = (UINT_PTR)RT_DIALOG // Dialog box
+ , rT_FONT = (UINT_PTR)RT_FONT // Font resource
+ , rT_FONTDIR = (UINT_PTR)RT_FONTDIR // Font directory resource
+ , rT_GROUP_CURSOR = (UINT_PTR)RT_GROUP_CURSOR // Hardware-independent cursor resource
+ , rT_GROUP_ICON = (UINT_PTR)RT_GROUP_ICON // Hardware-independent icon resource
+ , rT_HTML = (UINT_PTR)RT_HTML // HTML document
+ , rT_ICON = (UINT_PTR)RT_ICON // Hardware-dependent icon resource
+ , rT_MENU = (UINT_PTR)RT_MENU // Menu resource
+ , rT_MESSAGETABLE = (UINT_PTR)RT_MESSAGETABLE // Message-table entry
+ , rT_RCDATA = (UINT_PTR)RT_RCDATA // Application-defined resource (raw data)
+ , rT_STRING = (UINT_PTR)RT_STRING // String-table entry
+ , rT_VERSION = (UINT_PTR)RT_VERSION // Version resource
}
findResource :: HMODULE -> String -> ResourceType -> IO HRSRC
@@ -69,12 +69,12 @@ import Foreign hiding (unsafePerformIO)
#include <windows.h>
-#{enum HKEY, (unsafePerformIO . newForeignHANDLE . castUINTToPtr)
- , hKEY_CLASSES_ROOT = (UINT)HKEY_CLASSES_ROOT
- , hKEY_CURRENT_CONFIG = (UINT)HKEY_CURRENT_CONFIG
- , hKEY_CURRENT_USER = (UINT)HKEY_CURRENT_USER
- , hKEY_LOCAL_MACHINE = (UINT)HKEY_LOCAL_MACHINE
- , hKEY_USERS = (UINT)HKEY_USERS
+#{enum HKEY, (unsafePerformIO . newForeignHANDLE . castUINTPtrToPtr)
+ , hKEY_CLASSES_ROOT = (UINT_PTR)HKEY_CLASSES_ROOT
+ , hKEY_CURRENT_CONFIG = (UINT_PTR)HKEY_CURRENT_CONFIG
+ , hKEY_CURRENT_USER = (UINT_PTR)HKEY_CURRENT_USER
+ , hKEY_LOCAL_MACHINE = (UINT_PTR)HKEY_LOCAL_MACHINE
+ , hKEY_USERS = (UINT_PTR)HKEY_USERS
}
-- , PKEYERFORMANCE_DATA NT only
-- , HKEY_DYN_DATA 95/98 only
View
@@ -49,6 +49,8 @@ type LONG = Int32
type FLOAT = Float
type LARGE_INTEGER = Int64
+type UINT_PTR = Word
+
-- Not really a basic type, but used in many places
type DDWORD = Word64
@@ -141,8 +143,8 @@ type ForeignHANDLE = ForeignPtr ()
newForeignHANDLE :: HANDLE -> IO ForeignHANDLE
newForeignHANDLE = newForeignPtr deleteObjectFinaliser
-handleToWord :: HANDLE -> UINT
-handleToWord = castPtrToUINT
+handleToWord :: HANDLE -> UINT_PTR
+handleToWord = castPtrToUINTPtr
type HKEY = ForeignHANDLE
type PKEY = HANDLE
@@ -162,7 +164,7 @@ nullFinalHANDLE :: ForeignPtr a
nullFinalHANDLE = unsafePerformIO (newForeignPtr_ nullPtr)
iNVALID_HANDLE_VALUE :: HANDLE
-iNVALID_HANDLE_VALUE = castUINTToPtr 0xffffffff
+iNVALID_HANDLE_VALUE = castUINTPtrToPtr (-1)
----------------------------------------------------------------
-- Errors
@@ -268,10 +270,10 @@ foreign import ccall unsafe "HsWin32.h"
hIWORD :: DWORD -> WORD
foreign import ccall unsafe "HsWin32.h"
- castUINTToPtr :: UINT -> Ptr a
+ castUINTPtrToPtr :: UINT_PTR -> Ptr a
foreign import ccall unsafe "HsWin32.h"
- castPtrToUINT :: Ptr s -> UINT
+ castPtrToUINTPtr :: Ptr s -> UINT_PTR
foreign import ccall unsafe "HsWin32.h"
castFunPtrToLONG :: FunPtr a -> LONG
View
@@ -14,7 +14,7 @@ build-type: Simple
cabal-version: >=1.6
extra-source-files:
include/diatemp.h include/dumpBMP.h include/ellipse.h include/errors.h
- include/gettime.h include/Win32Aux.h include/win32debug.h
+ include/Win32Aux.h include/win32debug.h
Library
build-depends: base >= 3 && < 5, bytestring
View
@@ -12,8 +12,8 @@
# endif
#endif
-INLINE UINT castPtrToUINT(void *p) { return (UINT)p; }
-INLINE void *castUINTToPtr(UINT n) { return (void *)n; }
+INLINE UINT_PTR castPtrToUINTPtr(void *p) { return (UINT_PTR)p; }
+INLINE void *castUINTPtrToPtr(UINT_PTR n) { return (void *)n; }
INLINE LONG castFunPtrToLONG(void *p) { return (LONG)p; }
INLINE WORD hIWORD(DWORD w) { return HIWORD(w); }
INLINE WORD lOWORD(DWORD w) { return LOWORD(w); }
View
@@ -1,5 +0,0 @@
-#include <windows.h>
-
-/* Prototype missing from Cygwin B20.1 */
-
-extern DWORD WINAPI timeGetTime();

0 comments on commit f713147

Please sign in to comment.