]> git.saurik.com Git - wxWidgets.git/commitdiff
added a compile time assert to prevent wxArray from compiling when sizeof(long) ...
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 22 May 2002 18:04:36 +0000 (18:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 22 May 2002 18:04:36 +0000 (18:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15637 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/dynarray.cpp

index 61400eddf849f373de5ffbd1410a25ea125c7e08..25a7b4a31d0d868f45b3aa2d98e342733c21644d 100644 (file)
   #define max(a, b)   (((a) > (b)) ? (a) : (b))
 #endif
 
+// we cast the value to long from which we cast it to void * in IndexForInsert:
+// this can't work if the pointers are not big enough
+wxCOMPILE_TIME_ASSERT( sizeof(long) <= sizeof(void *),
+                       wxArraySizeOfPtrLessSizeOfLong ); // < 32 symbols
+
 // ============================================================================
 // constants
 // ============================================================================
@@ -219,7 +224,8 @@ size_t name::IndexForInsert(T lItem, CMPFUNC fnCompare) const               \
   while ( lo < hi ) {                                                       \
     i = (lo + hi)/2;                                                        \
                                                                             \
-    res = (*fnCompare)((const void *)lItem, (const void *)(m_pItems[i]));   \
+    res = (*fnCompare)((const void *)(long)lItem,                           \
+                       (const void *)(long)(m_pItems[i]));                  \
     if ( res < 0 )                                                          \
       hi = i;                                                               \
     else if ( res > 0 )                                                     \