The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Index: src/aui/framemanager.cpp
===================================================================
--- src/aui/framemanager.cpp	(revisione 63679)
+++ src/aui/framemanager.cpp	(copia locale)
@@ -973,7 +973,7 @@
     if (pinfo.name.empty() || already_exists)
     {
         pinfo.name.Printf(wxT("%08lx%08x%08x%08lx"),
-             ((unsigned long)pinfo.window) & 0xffffffff,
+             wxPtrToUInt(pinfo.window) & 0xffffffff,
              (unsigned int)time(NULL),
 #ifdef __WXWINCE__
              (unsigned int)GetTickCount(),
Index: src/common/utilscmn.cpp
===================================================================
--- src/common/utilscmn.cpp	(revisione 63679)
+++ src/common/utilscmn.cpp	(copia locale)
@@ -822,7 +822,7 @@
     //hInstApp member is only valid if the function fails, in which case it
     //receives one of the following error values, which are less than or
     //equal to 32.
-    const int nResult = (int) sei.hInstApp;
+    const int nResult = (INT_PTR) sei.hInstApp;

     // Firefox returns file not found for some reason, so make an exception
     // for it
Index: src/msw/dcprint.cpp
===================================================================
--- src/msw/dcprint.cpp	(revisione 63679)
+++ src/msw/dcprint.cpp	(copia locale)
@@ -319,7 +319,7 @@
     }
 
 
-    HGLOBAL hDevMode = (HGLOBAL)(DWORD) data->GetDevMode();
+    HGLOBAL hDevMode = (HGLOBAL) data->GetDevMode();
 
     DEVMODE *lpDevMode = hDevMode ? (DEVMODE *)::GlobalLock(hDevMode) : NULL;
 
Index: src/msw/window.cpp
===================================================================
--- src/msw/window.cpp	(revisione 63679)
+++ src/msw/window.cpp	(copia locale)
@@ -2596,8 +2596,8 @@
     // trace all messages - useful for the debugging
 #ifdef __WXDEBUG__
     wxLogTrace(wxTraceMessages,
-               wxT("Processing %s(hWnd=%08lx, wParam=%8lx, lParam=%8lx)"),
-               wxGetMessageName(message), (long)hWnd, (long)wParam, lParam);
+               wxT("Processing %s(hWnd=%p, wParam=%8lx, lParam=%8lx)"),
+               wxGetMessageName(message), hWnd, (long)wParam, lParam);
 #endif // __WXDEBUG__
 
     wxWindowMSW *wnd = wxFindWinFromHandle((WXHWND) hWnd);
@@ -3449,7 +3455,7 @@
 #ifdef __WXDEBUG__
     if ( oldWin && (oldWin != win) )
     {
-        wxLogDebug(wxT("HWND %X already associated with another window (%s)"),
-                   (int) hWnd, win->GetClassInfo()->GetClassName());
+        wxLogDebug(wxT("HWND %p already associated with another window (%s)"),
+                   hWnd, win->GetClassInfo()->GetClassName());
     }
     else
Index: src/msw/toplevel.cpp
===================================================================
--- src/msw/toplevel.cpp	(revisione 63679)
+++ src/msw/toplevel.cpp	(copia locale)
@@ -1122,7 +1122,7 @@
     {
         // restore focus to the child which was last focused unless we already
         // have it
-        wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd);
+        wxLogTrace(_T("focus"), _T("wxTLW %p activated."), m_hWnd);
 
         wxWindow *winFocus = FindFocus();
         if ( !winFocus || wxGetTopLevelParent(winFocus) != this )
@@ -1157,10 +1157,10 @@
         }
 
         wxLogTrace(_T("focus"),
-                   _T("wxTLW %08x deactivated, last focused: %08x."),
-                   (int) m_hWnd,
-                   (int) (m_winLastFocused ? GetHwndOf(m_winLastFocused)
-                                           : NULL));
+                   _T("wxTLW %p deactivated, last focused: %p."),
+                   m_hWnd,
+                   (m_winLastFocused ? GetHwndOf(m_winLastFocused)
+                                     : NULL));
 
         event.Skip();
     }
Index: src/msw/menuitem.cpp
===================================================================
--- src/msw/menuitem.cpp	(revisione 63679)
+++ src/msw/menuitem.cpp	(copia locale)
@@ -188,7 +188,7 @@
 // return the id for calling Win32 API functions
 int wxMenuItem::GetRealId() const
 {
-    return m_subMenu ? (int)m_subMenu->GetHMenu() : GetId();
+    return m_subMenu ? wxPtrToUInt(m_subMenu->GetHMenu()) : GetId();
 }
 
 // get item state
Index: src/msw/mdi.cpp
===================================================================
--- src/msw/mdi.cpp	(revisione 63679)
+++ src/msw/mdi.cpp	(copia locale)
@@ -763,7 +763,7 @@
   wxWindowCreationHook hook(this);
 
   m_hWnd = (WXHWND)::SendMessage(GetWinHwnd(parent->GetClientWindow()),
-                                 WM_MDICREATE, 0, (LONG)(LPSTR)&mcs);
+                                 WM_MDICREATE, 0, (LPARAM)&mcs);
 
   if ( !m_hWnd )
   {
@@ -1433,14 +1433,14 @@
             {
                 success = true;
                 ::InsertMenu(hmenu, i, MF_BYPOSITION | MF_POPUP | MF_STRING,
-                             (UINT)subMenu, _("&Window"));
+                             (UINT_PTR)subMenu, _("&Window"));
                 break;
             }
         }
 
         if ( !success )
         {
-            ::AppendMenu(hmenu, MF_POPUP, (UINT)subMenu, _("&Window"));
+            ::AppendMenu(hmenu, MF_POPUP, (UINT_PTR)subMenu, _("&Window"));
         }
     }
 
Index: src/msw/tooltip.cpp
===================================================================
--- src/msw/tooltip.cpp	(revisione 63679)
+++ src/msw/tooltip.cpp	(copia locale)
@@ -106,7 +106,7 @@
             uFlags |= TTF_TRANSPARENT;
         }
 
-        uId = (UINT)hwndOwner;
+        uId = (UINT_PTR)hwndOwner;
     }
 };
 
Index: src/msw/menu.cpp
===================================================================
--- src/msw/menu.cpp	(revisione 63679)
+++ src/msw/menu.cpp	(copia locale)
@@ -370,14 +370,14 @@
 
     // id is the numeric id for normal menu items and HMENU for submenus as
     // required by ::AppendMenu() API
-    UINT id;
+    UINT_PTR id;
     wxMenu *submenu = pItem->GetSubMenu();
     if ( submenu != NULL ) {
         wxASSERT_MSG( submenu->GetHMenu(), wxT("invalid submenu") );
 
         submenu->SetParent(this);
 
-        id = (UINT)submenu->GetHMenu();
+        id = (UINT_PTR)submenu->GetHMenu();
 
         flags |= MF_POPUP;
     }
@@ -963,7 +963,7 @@
         for ( i = 0, it = m_menus.begin(); i < count; i++, it++ )
         {
             if ( !::AppendMenu((HMENU)m_hMenu, MF_POPUP | MF_STRING,
-                               (UINT)(*it)->GetHMenu(),
+                               (UINT_PTR)(*it)->GetHMenu(),
                                m_titles[i]) )
             {
                 wxLogLastError(wxT("AppendMenu"));
@@ -1035,7 +1035,7 @@
 
     int mswpos = MSWPositionForWxMenu(GetMenu(pos),pos);
 
-    UINT id;
+    UINT_PTR id;
     UINT flagsOld = ::GetMenuState((HMENU)m_hMenu, mswpos, MF_BYPOSITION);
     if ( flagsOld == 0xFFFFFFFF )
     {
@@ -1048,7 +1048,7 @@
     {
         // HIBYTE contains the number of items in the submenu in this case
         flagsOld &= 0xff;
-        id = (UINT)::GetSubMenu((HMENU)m_hMenu, mswpos);
+        id = (UINT_PTR)::GetSubMenu((HMENU)m_hMenu, mswpos);
     }
     else
     {
@@ -1124,7 +1124,7 @@
 
         if ( !::InsertMenu(GetHmenu(), (UINT)mswpos,
                            MF_BYPOSITION | MF_POPUP | MF_STRING,
-                           (UINT)GetHmenuOf(menu), title) )
+                           (UINT_PTR)GetHmenuOf(menu), title) )
         {
             wxLogLastError(wxT("InsertMenu"));
         }
@@ -1191,7 +1191,7 @@
 #else
         if ( !::InsertMenu(GetHmenu(), mswpos,
                            MF_BYPOSITION | MF_POPUP | MF_STRING,
-                           (UINT)GetHmenuOf(menu), title) )
+                           (UINT_PTR)GetHmenuOf(menu), title) )
         {
             wxLogLastError(wxT("InsertMenu"));
         }
@@ -1250,7 +1250,7 @@
         }
 #else
         if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING,
-                           (UINT)submenu, title) )
+                           (UINT_PTR)submenu, title) )
         {
             wxLogLastError(wxT("AppendMenu"));
         }
Index: src/msw/tbar95.cpp
===================================================================
--- src/msw/tbar95.cpp	(revisione 63679)
+++ src/msw/tbar95.cpp	(copia locale)
@@ -802,8 +802,8 @@
                 TBREPLACEBITMAP replaceBitmap;
                 replaceBitmap.hInstOld = NULL;
                 replaceBitmap.hInstNew = NULL;
-                replaceBitmap.nIDOld = (UINT) oldToolBarBitmap;
-                replaceBitmap.nIDNew = (UINT) hBitmap;
+                replaceBitmap.nIDOld = (UINT_PTR) oldToolBarBitmap;
+                replaceBitmap.nIDNew = (UINT_PTR) hBitmap;
                 replaceBitmap.nButtons = nButtons;
                 if ( !::SendMessage(GetHwnd(), TB_REPLACEBITMAP,
                                     0, (LPARAM) &replaceBitmap) )
@@ -832,7 +832,7 @@
         {
             TBADDBITMAP addBitmap;
             addBitmap.hInst = 0;
-            addBitmap.nID = (UINT) hBitmap;
+            addBitmap.nID = (UINT_PTR) hBitmap;
             if ( ::SendMessage(GetHwnd(), TB_ADDBITMAP,
                                (WPARAM) nButtons, (LPARAM)&addBitmap) == -1 )
             {
@@ -912,7 +912,7 @@
                 {
                     const wxString& label = tool->GetLabel();
                     if ( !label.empty() )
-                        button.iString = (int)label.c_str();
+                        button.iString = (INT_PTR)label.c_str();
                 }
 
                 button.idCommand = tool->GetId();
Index: src/msw/thread.cpp
===================================================================
--- src/msw/thread.cpp	(revisione 63679)
+++ src/msw/thread.cpp	(copia locale)
@@ -522,7 +522,7 @@
             return (THREAD_RETVAL)-1;
         }
 
-        rc = (THREAD_RETVAL)thread->Entry();
+        rc = wxPtrToUInt(thread->Entry());
     }
     wxCATCH_ALL( wxTheApp->OnUnhandledException(); )
 
@@ -684,7 +684,7 @@
     // from Wait()) or ask it to terminate (when called from Delete())
     bool shouldDelete = threadToDelete != NULL;
 
-    wxThread::ExitCode rc = 0;
+    DWORD rc = 0;
 
     // we might need to resume the thread if it's currently stopped
     bool shouldResume = false;
@@ -837,12 +837,12 @@
         {
             wxLogLastError(wxT("GetExitCodeThread"));
 
-            rc = (wxThread::ExitCode)-1;
+            rc = (THREAD_RETVAL)-1;
 
             break;
         }
 
-        if ( (DWORD)rc != STILL_ACTIVE )
+        if ( rc != STILL_ACTIVE )
             break;
 
         // give the other thread some time to terminate, otherwise we may be
@@ -851,14 +851,14 @@
     }
 
     if ( pRc )
-        *pRc = rc;
+        *pRc = wxUIntToPtr(rc);
 
     // we don't need the thread handle any more in any case
     Free();
 
 
-    return rc == (wxThread::ExitCode)-1 ? wxTHREAD_MISC_ERROR
-                                        : wxTHREAD_NO_ERROR;
+    return rc == (THREAD_RETVAL)-1 ? wxTHREAD_MISC_ERROR
+                                   : wxTHREAD_NO_ERROR;
 }
 
 bool wxThreadInternal::Suspend()
@@ -1162,7 +1162,7 @@
     }
 
 #ifdef wxUSE_BEGIN_THREAD
-    _endthreadex((unsigned)status);
+    _endthreadex(wxPtrToUInt(status));
 #else // !VC++
     ::ExitThread((DWORD)status);
 #endif // VC++/!VC++
Index: src/msw/frame.cpp
===================================================================
--- src/msw/frame.cpp	(revisione 63679)
+++ src/msw/frame.cpp	(copia locale)
@@ -855,7 +855,8 @@
             HDC hdc = ::BeginPaint(GetHwnd(), &ps);
 
             // Erase background before painting or we get white background
-            MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L);
+            // Commented out: according to MSDN it's only needed on NT 3.51
+            // MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L);
 
             if ( hIcon )
             {
@@ -1080,7 +1081,7 @@
                 const wxIcon& icon = GetIcon();
                 HICON hIcon = icon.Ok() ? GetHiconOf(icon)
                                         : (HICON)GetDefaultIcon();
-                rc = (long)hIcon;
+                rc = (WXLRESULT)hIcon;
                 processed = rc != 0;
             }
             break;
Index: src/msw/pen.cpp
===================================================================
--- src/msw/pen.cpp	(revisione 63679)
+++ src/msw/pen.cpp	(copia locale)
@@ -172,7 +172,7 @@
            case wxSTIPPLE:
                logb.lbStyle = BS_PATTERN ;
                if (M_PENDATA->m_stipple.Ok())
-                   logb.lbHatch = (LONG)M_PENDATA->m_stipple.GetHBITMAP();
+                   logb.lbHatch = wxPtrToUInt(M_PENDATA->m_stipple.GetHBITMAP());
                else
                    logb.lbHatch = (LONG)0;
                break;
Index: src/msw/helpwin.cpp
===================================================================
--- src/msw/helpwin.cpp	(revisione 63679)
+++ src/msw/helpwin.cpp	(copia locale)
@@ -98,7 +98,7 @@
 
     wxString str = GetValidFilename(m_helpFile);
 
-    return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_PARTIALKEY, (DWORD)(const wxChar*) k) != 0);
+    return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_PARTIALKEY, (ULONG_PTR)(const wxChar*) k) != 0);
 }
 
 // Can't close the help window explicitly in WinHelp
Index: src/msw/printdlg.cpp
===================================================================
--- src/msw/printdlg.cpp	(revisione 63679)
+++ src/msw/printdlg.cpp	(copia locale)
@@ -175,10 +175,10 @@
 
 wxWindowsPrintNativeData::~wxWindowsPrintNativeData()
 {
-    HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
+    HGLOBAL hDevMode = (HGLOBAL) m_devMode;
     if ( hDevMode )
         GlobalFree(hDevMode);
-    HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
+    HGLOBAL hDevNames = (HGLOBAL) m_devNames;
     if ( hDevNames )
         GlobalFree(hDevNames);
 }
@@ -190,8 +190,8 @@
 
 bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data )
 {
-    HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
-    HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
+    HGLOBAL hDevMode = (HGLOBAL) m_devMode;
+    HGLOBAL hDevNames = (HGLOBAL) m_devNames;
 
     if (!hDevMode)
     {
@@ -396,8 +396,8 @@
 
 bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
 {
-    HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
-    HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
+    HGLOBAL hDevMode = (HGLOBAL) m_devMode;
+    HGLOBAL hDevNames = (HGLOBAL) m_devNames;
     WinPrinter printer;
     LPTSTR szPrinterName = (LPTSTR)data.GetPrinterName().wx_str();
 
@@ -452,18 +452,12 @@
         // Use PRINTDLG as a way of creating a DEVMODE object
         PRINTDLG pd;
 
-        // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
-#ifdef __GNUWIN32__
-        memset(&pd, 0, 66);
-        pd.lStructSize    = 66;
-#else
         memset(&pd, 0, sizeof(PRINTDLG));
 #ifdef __WXWINCE__
         pd.cbStruct    = sizeof(PRINTDLG);
 #else
         pd.lStructSize    = sizeof(PRINTDLG);
 #endif
-#endif
 
         pd.hwndOwner      = (HWND)NULL;
         pd.hDevMode       = NULL; // Will be created by PrintDlg
@@ -493,7 +487,7 @@
         else
         {
             hDevMode = pd.hDevMode;
-            m_devMode = (void*)(long) hDevMode;
+            m_devMode = (void*) hDevMode;
             pd.hDevMode = NULL;
 
             // We'll create a new DEVNAMEs structure below.
@@ -688,7 +682,7 @@
     }
 
     // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
-    m_devNames = (void*) (long) wxCreateDevNames(wxEmptyString, data.GetPrinterName(), wxEmptyString);
+    m_devNames = wxCreateDevNames(wxEmptyString, data.GetPrinterName(), wxEmptyString);
 
     return true;
 }
@@ -797,12 +791,8 @@
     memset( pd, 0, sizeof(PRINTDLG) );
     m_printDlg = (void*) pd;
 
-    // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
-#ifdef __GNUWIN32__
-    pd->lStructSize    = 66;
-#else
     pd->lStructSize    = sizeof(PRINTDLG);
-#endif
+
     pd->hwndOwner      = (HWND)NULL;
     pd->hDevMode       = NULL; // Will be created by PrintDlg
     pd->hDevNames      = NULL; // Ditto
@@ -820,13 +810,13 @@
     if (pd->hDevNames)
         GlobalFree(pd->hDevNames);
 
-    pd->hDevMode = (HGLOBAL)(DWORD) native_data->GetDevMode();
+    pd->hDevMode = (HGLOBAL) native_data->GetDevMode();
     native_data->SetDevMode( (void*) NULL);
 
     // Shouldn't assert; we should be able to test Ok-ness at a higher level
     //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
 
-    pd->hDevNames = (HGLOBAL)(DWORD) native_data->GetDevNames();
+    pd->hDevNames = (HGLOBAL) native_data->GetDevNames();
     native_data->SetDevNames( (void*) NULL);
 
 
@@ -839,11 +829,7 @@
 
     pd->Flags = PD_RETURNDC;
 
-#ifdef __GNUWIN32__
-    pd->lStructSize = 66;
-#else
     pd->lStructSize = sizeof( PRINTDLG );
-#endif
 
     pd->hwndOwner=(HWND)NULL;
 //    pd->hDevNames=(HANDLE)NULL;
@@ -897,9 +883,9 @@
         if (native_data->GetDevMode())
         {
             // Make sure we don't leak memory
-            GlobalFree( (HGLOBAL)(DWORD) native_data->GetDevMode() );
+            GlobalFree( (HGLOBAL) native_data->GetDevMode() );
         }
-        native_data->SetDevMode( (void*)(long) pd->hDevMode );
+        native_data->SetDevMode( (void*) pd->hDevMode );
         pd->hDevMode = NULL;
     }
 
@@ -909,9 +895,9 @@
         if (native_data->GetDevNames())
         {
             // Make sure we don't leak memory
-            GlobalFree((HGLOBAL)(DWORD) native_data->GetDevNames());
+            GlobalFree((HGLOBAL) native_data->GetDevNames());
         }
-        native_data->SetDevNames((void*)(long) pd->hDevNames);
+        native_data->SetDevNames((void*) pd->hDevNames);
         pd->hDevNames = NULL;
     }

Index: src/msw/textctrl.cpp
===================================================================
--- src/msw/textctrl.cpp	2009-03-06 13:11:24.000000000 +0100
+++ src/msw/textctrl.cpp	2010-03-13 22:50:54.000000000 +0100
@@ -960,7 +960,7 @@
     // finally, stream it in the control
     EDITSTREAM eds;
     wxZeroMemory(eds);
-    eds.dwCookie = (DWORD)&wpc;
+    eds.dwCookie = (DWORD_PTR)&wpc;
     // the cast below is needed for broken (very) old mingw32 headers
     eds.pfnCallback = (EDITSTREAMCALLBACK)wxRichEditStreamIn;
 
Index: include/wx/defs.h
--- include/wx/defs.h	2009-03-06 13:10:51.000000000 +0100
+++ include/wx/defs.h	2010-03-20 14:17:40.000000000 +0100
@@ -823,75 +823,6 @@
 
 typedef wxUint32 wxDword;
 
-/*
-   Define an integral type big enough to contain all of long, size_t and void *.
- */
-#if SIZEOF_LONG >= SIZEOF_VOID_P && SIZEOF_LONG >= SIZEOF_SIZE_T
-    /* normal case */
-    typedef unsigned long wxUIntPtr;
-    typedef long wxIntPtr;
-#elif SIZEOF_SIZE_T >= SIZEOF_VOID_P
-    /* Win64 case */
-    typedef size_t wxUIntPtr;
-    #define wxIntPtr ssize_t
-#else
-    /*
-       This should never happen for the current architectures but if you're
-       using one where it does, please contact wx-dev@lists.wxwidgets.org.
-     */
-    #error "Pointers can't be stored inside integer types."
-#endif
-
-#ifdef __cplusplus
-/* And also define a couple of simple functions to cast pointer to/from it. */
-inline wxUIntPtr wxPtrToUInt(const void *p)
-{
-    /*
-       VC++ 7.1 gives warnings about casts such as below even when they're
-       explicit with /Wp64 option, suppress them as we really know what we're
-       doing here. Same thing with icc with -Wall.
-     */
-#ifdef __VISUALC__
-    #if __VISUALC__ >= 1200
-        #pragma warning(push)
-    #endif
-    /* pointer truncation from '' to '' */
-    #pragma warning(disable: 4311)
-#elif defined(__INTELC__)
-    #pragma warning(push)
-    /* conversion from pointer to same-sized integral type */
-    #pragma warning(disable: 1684)
-#endif
-
-    return wx_reinterpret_cast(wxUIntPtr, p);
-
-#if (defined(__VISUALC__) && __VISUALC__ >= 1200) || defined(__INTELC__)
-    #pragma warning(pop)
-#endif
-}
-
-inline void *wxUIntToPtr(wxUIntPtr p)
-{
-#ifdef __VISUALC__
-    #if __VISUALC__ >= 1200
-        #pragma warning(push)
-    #endif
-    /* conversion to type of greater size */
-    #pragma warning(disable: 4312)
-#elif defined(__INTELC__)
-    #pragma warning(push)
-    /* invalid type conversion: "wxUIntPtr={unsigned long}" to "void *" */
-    #pragma warning(disable: 171)
-#endif
-
-    return wx_reinterpret_cast(void *, p);
-
-#if (defined(__VISUALC__) && __VISUALC__ >= 1200) || defined(__INTELC__)
-    #pragma warning(pop)
-#endif
-}
-#endif /*__cplusplus*/
-
 
 /*  64 bit */
 
@@ -1021,6 +954,87 @@
 #endif
 
 
+// we can't rely on Windows _W64 being defined as windows.h may not be included
+// so define our own equivalent: this should be used with types like WXLPARAM
+// or WXWPARAM which are 64 bit under Win64 to avoid warnings each time we cast
+// it to a pointer or a handle (which results in hundreds of warnings as Win32
+// API often passes pointers in them)
+#if defined(__VISUALC__) && __VISUALC__ >= 1300
+    #define wxW64 __w64
+#else
+    #define wxW64
+#endif
+
+/*
+   Define an integral type big enough to contain all of long, size_t and void *.
+ */
+#if SIZEOF_LONG >= SIZEOF_VOID_P && SIZEOF_LONG >= SIZEOF_SIZE_T
+    /* normal case */
+    typedef long wxIntPtr;
+    typedef unsigned long wxUIntPtr;
+#elif SIZEOF_SIZE_T >= SIZEOF_VOID_P
+    /* Win64 case */
+    typedef wxW64 ssize_t wxIntPtr;
+    typedef size_t wxUIntPtr;
+#else
+    /*
+       This should never happen for the current architectures but if you're
+       using one where it does, please contact wx-dev@lists.wxwidgets.org.
+     */
+    #error "Pointers can't be stored inside integer types."
+#endif
+
+#ifdef __cplusplus
+/* And also define a couple of simple functions to cast pointer to/from it. */
+inline wxUIntPtr wxPtrToUInt(const void *p)
+{
+    /*
+       VC++ 7.1 gives warnings about casts such as below even when they're
+       explicit with /Wp64 option, suppress them as we really know what we're
+       doing here. Same thing with icc with -Wall.
+     */
+#ifdef __VISUALC__
+    #if __VISUALC__ >= 1200
+        #pragma warning(push)
+    #endif
+    /* pointer truncation from '' to '' */
+    #pragma warning(disable: 4311)
+#elif defined(__INTELC__)
+    #pragma warning(push)
+    /* conversion from pointer to same-sized integral type */
+    #pragma warning(disable: 1684)
+#endif
+
+    return wx_reinterpret_cast(wxUIntPtr, p);
+
+#if (defined(__VISUALC__) && __VISUALC__ >= 1200) || defined(__INTELC__)
+    #pragma warning(pop)
+#endif
+}
+
+inline void *wxUIntToPtr(wxUIntPtr p)
+{
+#ifdef __VISUALC__
+    #if __VISUALC__ >= 1200
+        #pragma warning(push)
+    #endif
+    /* conversion to type of greater size */
+    #pragma warning(disable: 4312)
+#elif defined(__INTELC__)
+    #pragma warning(push)
+    /* invalid type conversion: "wxUIntPtr={unsigned long}" to "void *" */
+    #pragma warning(disable: 171)
+#endif
+
+    return wx_reinterpret_cast(void *, p);
+
+#if (defined(__VISUALC__) && __VISUALC__ >= 1200) || defined(__INTELC__)
+    #pragma warning(pop)
+#endif
+}
+#endif /*__cplusplus*/
+
+
 /*  base floating point types */
 /*  wxFloat32: 32 bit IEEE float ( 1 sign, 8 exponent bits, 23 fraction bits */
 /*  wxFloat64: 64 bit IEEE float ( 1 sign, 11 exponent bits, 52 fraction bits */