From 649deb111a12c2072cc663942d72cab5726d9e38 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 2 Jun 2014 13:15:19 +0000 Subject: [PATCH] Explicitly convert int to HANDLE to fix 64 bit wxMSW build. This fixes g++ compilation problem in 64 bit mode after the changes of r76653, it complained about comparing pointer (HANDLE) with an integer. It might also fix compilation with icc. See #16233. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76658 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/private.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index 001d489037..dabb41107a 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -189,9 +189,9 @@ template class AutoHANDLE { public: - wxEXPLICIT AutoHANDLE(HANDLE handle = INVALID_VALUE) : m_handle(handle) { } + wxEXPLICIT AutoHANDLE(HANDLE handle = InvalidHandle()) : m_handle(handle) { } - bool IsOk() const { return m_handle != INVALID_VALUE; } + bool IsOk() const { return m_handle != InvalidHandle(); } operator HANDLE() const { return m_handle; } ~AutoHANDLE() { if ( IsOk() ) DoClose(); } @@ -202,10 +202,17 @@ public: DoClose(); - m_handle = INVALID_VALUE; + m_handle = InvalidHandle(); } protected: + // We need this helper function because integer INVALID_VALUE is not + // implicitly convertible to HANDLE, which is a pointer. + static HANDLE InvalidHandle() + { + return static_cast(INVALID_VALUE); + } + void DoClose() { if ( !::CloseHandle(m_handle) )