Skip to content

Commit f713147

Browse files
committed
Fix warnings on Win64
Mostly this meant using UINT_PTR instead of UINT.
1 parent 690c205 commit f713147

File tree

9 files changed

+56
-60
lines changed

9 files changed

+56
-60
lines changed

Graphics/Win32/Dialogue.hsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ mkDialogTemplate = newTString
4343
type ResourceID = Int
4444

4545
mkResource :: ResourceID -> IO (Ptr a)
46-
mkResource res = return (castUINTToPtr (fromIntegral res))
46+
mkResource res = return (castUINTPtrToPtr (fromIntegral res))
4747

4848
mkDialogTemplateFromResource :: Int -> IO DTemplate
4949
mkDialogTemplateFromResource = mkResource

Graphics/Win32/GDI/Types.hsc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ type MbHDWP = Maybe HDWP
215215
type HWND = HANDLE
216216
type MbHWND = Maybe HWND
217217

218-
#{enum HWND, castUINTToPtr
219-
, hWND_BOTTOM = HWND_BOTTOM
220-
, hWND_NOTOPMOST = HWND_NOTOPMOST
221-
, hWND_TOP = HWND_TOP
222-
, hWND_TOPMOST = HWND_TOPMOST
218+
#{enum HWND, castUINTPtrToPtr
219+
, hWND_BOTTOM = (UINT_PTR)HWND_BOTTOM
220+
, hWND_NOTOPMOST = (UINT_PTR)HWND_NOTOPMOST
221+
, hWND_TOP = (UINT_PTR)HWND_TOP
222+
, hWND_TOPMOST = (UINT_PTR)HWND_TOPMOST
223223
}
224224

225225
type HMENU = HANDLE

Graphics/Win32/Misc.hsc

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import Data.Maybe
2424
import Foreign
2525

2626
#include <windows.h>
27-
#include "gettime.h"
2827

2928
----------------------------------------------------------------
3029
-- Resources
@@ -63,24 +62,24 @@ loadIcon mb_inst icon =
6362
foreign import stdcall unsafe "windows.h LoadIconW"
6463
c_LoadIcon :: HINSTANCE -> Icon -> IO HICON
6564

66-
#{enum Cursor, castUINTToPtr
67-
, iDC_ARROW = (UINT)IDC_ARROW
68-
, iDC_IBEAM = (UINT)IDC_IBEAM
69-
, iDC_WAIT = (UINT)IDC_WAIT
70-
, iDC_CROSS = (UINT)IDC_CROSS
71-
, iDC_UPARROW = (UINT)IDC_UPARROW
72-
, iDC_SIZENWSE = (UINT)IDC_SIZENWSE
73-
, iDC_SIZENESW = (UINT)IDC_SIZENESW
74-
, iDC_SIZEWE = (UINT)IDC_SIZEWE
75-
, iDC_SIZENS = (UINT)IDC_SIZENS
65+
#{enum Cursor, castUINTPtrToPtr
66+
, iDC_ARROW = (UINT_PTR)IDC_ARROW
67+
, iDC_IBEAM = (UINT_PTR)IDC_IBEAM
68+
, iDC_WAIT = (UINT_PTR)IDC_WAIT
69+
, iDC_CROSS = (UINT_PTR)IDC_CROSS
70+
, iDC_UPARROW = (UINT_PTR)IDC_UPARROW
71+
, iDC_SIZENWSE = (UINT_PTR)IDC_SIZENWSE
72+
, iDC_SIZENESW = (UINT_PTR)IDC_SIZENESW
73+
, iDC_SIZEWE = (UINT_PTR)IDC_SIZEWE
74+
, iDC_SIZENS = (UINT_PTR)IDC_SIZENS
7675
}
7776

78-
#{enum Icon, castUINTToPtr
79-
, iDI_APPLICATION = (UINT)IDI_APPLICATION
80-
, iDI_HAND = (UINT)IDI_HAND
81-
, iDI_QUESTION = (UINT)IDI_QUESTION
82-
, iDI_EXCLAMATION = (UINT)IDI_EXCLAMATION
83-
, iDI_ASTERISK = (UINT)IDI_ASTERISK
77+
#{enum Icon, castUINTPtrToPtr
78+
, iDI_APPLICATION = (UINT_PTR)IDI_APPLICATION
79+
, iDI_HAND = (UINT_PTR)IDI_HAND
80+
, iDI_QUESTION = (UINT_PTR)IDI_QUESTION
81+
, iDI_EXCLAMATION = (UINT_PTR)IDI_EXCLAMATION
82+
, iDI_ASTERISK = (UINT_PTR)IDI_ASTERISK
8483
}
8584

8685
----------------------------------------------------------------

Graphics/Win32/Resource.hsc

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@ foreign import stdcall unsafe "windows.h EndUpdateResourceW"
5656

5757
type ResourceType = LPCTSTR
5858

59-
#{enum ResourceType, castUINTToPtr
60-
, rT_ACCELERATOR = (UINT)RT_ACCELERATOR // Accelerator table
61-
, rT_ANICURSOR = (UINT)RT_ANICURSOR // Animated cursor
62-
, rT_ANIICON = (UINT)RT_ANIICON // Animated icon
63-
, rT_BITMAP = (UINT)RT_BITMAP // Bitmap resource
64-
, rT_CURSOR = (UINT)RT_CURSOR // Hardware-dependent cursor resource
65-
, rT_DIALOG = (UINT)RT_DIALOG // Dialog box
66-
, rT_FONT = (UINT)RT_FONT // Font resource
67-
, rT_FONTDIR = (UINT)RT_FONTDIR // Font directory resource
68-
, rT_GROUP_CURSOR = (UINT)RT_GROUP_CURSOR // Hardware-independent cursor resource
69-
, rT_GROUP_ICON = (UINT)RT_GROUP_ICON // Hardware-independent icon resource
70-
, rT_HTML = (UINT)RT_HTML // HTML document
71-
, rT_ICON = (UINT)RT_ICON // Hardware-dependent icon resource
72-
, rT_MENU = (UINT)RT_MENU // Menu resource
73-
, rT_MESSAGETABLE = (UINT)RT_MESSAGETABLE // Message-table entry
74-
, rT_RCDATA = (UINT)RT_RCDATA // Application-defined resource (raw data)
75-
, rT_STRING = (UINT)RT_STRING // String-table entry
76-
, rT_VERSION = (UINT)RT_VERSION // Version resource
59+
#{enum ResourceType, castUINTPtrToPtr
60+
, rT_ACCELERATOR = (UINT_PTR)RT_ACCELERATOR // Accelerator table
61+
, rT_ANICURSOR = (UINT_PTR)RT_ANICURSOR // Animated cursor
62+
, rT_ANIICON = (UINT_PTR)RT_ANIICON // Animated icon
63+
, rT_BITMAP = (UINT_PTR)RT_BITMAP // Bitmap resource
64+
, rT_CURSOR = (UINT_PTR)RT_CURSOR // Hardware-dependent cursor resource
65+
, rT_DIALOG = (UINT_PTR)RT_DIALOG // Dialog box
66+
, rT_FONT = (UINT_PTR)RT_FONT // Font resource
67+
, rT_FONTDIR = (UINT_PTR)RT_FONTDIR // Font directory resource
68+
, rT_GROUP_CURSOR = (UINT_PTR)RT_GROUP_CURSOR // Hardware-independent cursor resource
69+
, rT_GROUP_ICON = (UINT_PTR)RT_GROUP_ICON // Hardware-independent icon resource
70+
, rT_HTML = (UINT_PTR)RT_HTML // HTML document
71+
, rT_ICON = (UINT_PTR)RT_ICON // Hardware-dependent icon resource
72+
, rT_MENU = (UINT_PTR)RT_MENU // Menu resource
73+
, rT_MESSAGETABLE = (UINT_PTR)RT_MESSAGETABLE // Message-table entry
74+
, rT_RCDATA = (UINT_PTR)RT_RCDATA // Application-defined resource (raw data)
75+
, rT_STRING = (UINT_PTR)RT_STRING // String-table entry
76+
, rT_VERSION = (UINT_PTR)RT_VERSION // Version resource
7777
}
7878

7979
findResource :: HMODULE -> String -> ResourceType -> IO HRSRC

System/Win32/Registry.hsc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ import Foreign hiding (unsafePerformIO)
6969

7070
#include <windows.h>
7171

72-
#{enum HKEY, (unsafePerformIO . newForeignHANDLE . castUINTToPtr)
73-
, hKEY_CLASSES_ROOT = (UINT)HKEY_CLASSES_ROOT
74-
, hKEY_CURRENT_CONFIG = (UINT)HKEY_CURRENT_CONFIG
75-
, hKEY_CURRENT_USER = (UINT)HKEY_CURRENT_USER
76-
, hKEY_LOCAL_MACHINE = (UINT)HKEY_LOCAL_MACHINE
77-
, hKEY_USERS = (UINT)HKEY_USERS
72+
#{enum HKEY, (unsafePerformIO . newForeignHANDLE . castUINTPtrToPtr)
73+
, hKEY_CLASSES_ROOT = (UINT_PTR)HKEY_CLASSES_ROOT
74+
, hKEY_CURRENT_CONFIG = (UINT_PTR)HKEY_CURRENT_CONFIG
75+
, hKEY_CURRENT_USER = (UINT_PTR)HKEY_CURRENT_USER
76+
, hKEY_LOCAL_MACHINE = (UINT_PTR)HKEY_LOCAL_MACHINE
77+
, hKEY_USERS = (UINT_PTR)HKEY_USERS
7878
}
7979
-- , PKEYERFORMANCE_DATA NT only
8080
-- , HKEY_DYN_DATA 95/98 only

System/Win32/Types.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ type LONG = Int32
4949
type FLOAT = Float
5050
type LARGE_INTEGER = Int64
5151

52+
type UINT_PTR = Word
53+
5254
-- Not really a basic type, but used in many places
5355
type DDWORD = Word64
5456

@@ -141,8 +143,8 @@ type ForeignHANDLE = ForeignPtr ()
141143
newForeignHANDLE :: HANDLE -> IO ForeignHANDLE
142144
newForeignHANDLE = newForeignPtr deleteObjectFinaliser
143145

144-
handleToWord :: HANDLE -> UINT
145-
handleToWord = castPtrToUINT
146+
handleToWord :: HANDLE -> UINT_PTR
147+
handleToWord = castPtrToUINTPtr
146148

147149
type HKEY = ForeignHANDLE
148150
type PKEY = HANDLE
@@ -162,7 +164,7 @@ nullFinalHANDLE :: ForeignPtr a
162164
nullFinalHANDLE = unsafePerformIO (newForeignPtr_ nullPtr)
163165

164166
iNVALID_HANDLE_VALUE :: HANDLE
165-
iNVALID_HANDLE_VALUE = castUINTToPtr 0xffffffff
167+
iNVALID_HANDLE_VALUE = castUINTPtrToPtr (-1)
166168

167169
----------------------------------------------------------------
168170
-- Errors
@@ -268,10 +270,10 @@ foreign import ccall unsafe "HsWin32.h"
268270
hIWORD :: DWORD -> WORD
269271

270272
foreign import ccall unsafe "HsWin32.h"
271-
castUINTToPtr :: UINT -> Ptr a
273+
castUINTPtrToPtr :: UINT_PTR -> Ptr a
272274

273275
foreign import ccall unsafe "HsWin32.h"
274-
castPtrToUINT :: Ptr s -> UINT
276+
castPtrToUINTPtr :: Ptr s -> UINT_PTR
275277

276278
foreign import ccall unsafe "HsWin32.h"
277279
castFunPtrToLONG :: FunPtr a -> LONG

Win32.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build-type: Simple
1414
cabal-version: >=1.6
1515
extra-source-files:
1616
include/diatemp.h include/dumpBMP.h include/ellipse.h include/errors.h
17-
include/gettime.h include/Win32Aux.h include/win32debug.h
17+
include/Win32Aux.h include/win32debug.h
1818

1919
Library
2020
build-depends: base >= 3 && < 5, bytestring

include/HsWin32.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# endif
1313
#endif
1414

15-
INLINE UINT castPtrToUINT(void *p) { return (UINT)p; }
16-
INLINE void *castUINTToPtr(UINT n) { return (void *)n; }
15+
INLINE UINT_PTR castPtrToUINTPtr(void *p) { return (UINT_PTR)p; }
16+
INLINE void *castUINTPtrToPtr(UINT_PTR n) { return (void *)n; }
1717
INLINE LONG castFunPtrToLONG(void *p) { return (LONG)p; }
1818
INLINE WORD hIWORD(DWORD w) { return HIWORD(w); }
1919
INLINE WORD lOWORD(DWORD w) { return LOWORD(w); }

include/gettime.h

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)