]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxPtrToUInt() to cast pointer to an integer type without warnings
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 28 Sep 2004 21:48:47 +0000 (21:48 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 28 Sep 2004 21:48:47 +0000 (21:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29513 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/defs.h

index 56edd148398d2765c55690562ce6fb7ff4d57487..92167acc7d90c6d5dd7f3f77e1b881284ece8079 100644 (file)
@@ -740,6 +740,24 @@ typedef wxUint32 wxDword;
     #error "Pointers can't be stored inside integer types."
 #endif
 
+/* And also define a simple function to cast pointer to it. */
+inline wxUIntPtr wxPtrToUInt(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
+#ifdef __VISUALC__
+    #pragma warning(disable: 4311) /* pointer truncation from '' to '' */
+#endif
+
+    return wx_reinterpret_cast(wxUIntPtr, p);
+
+#ifdef __VISUALC__
+    #pragma warning(default: 4311)
+#endif
+}
+
+
 /*  64 bit */
 
 /*  NB: we #define and not typedef wxLongLong_t because we want to be able to */