]> git.saurik.com Git - wxWidgets.git/commitdiff
Correct fix to the compile time assert under OW. Kudos to Vadim to the tip.
authorWłodzimierz Skiba <abx@abx.art.pl>
Wed, 20 Oct 2004 01:20:58 +0000 (01:20 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Wed, 20 Oct 2004 01:20:58 +0000 (01:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30030 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/debug.h
include/wx/thread.h
src/common/filename.cpp
src/msw/cursor.cpp
src/msw/listctrl.cpp
src/msw/thread.cpp

index 6af819ed92505c76a9c23832539a66f6f084d421..2876fa528617e4f4b1cccf04da97e6b8013d5720 100644 (file)
 
  It may be used both within a function and in the global scope.
 */
-#define wxCOMPILE_TIME_ASSERT(expr, msg) \
-    struct wxMAKE_UNIQUE_ASSERT_NAME { unsigned int msg: expr; }
+#ifdef __WATCOMC__
+    /* avoid "unused symbol" warning */
+    #define wxCOMPILE_TIME_ASSERT(expr, msg) \
+        class wxMAKE_UNIQUE_ASSERT_NAME { \
+          unsigned int msg: expr; \
+          wxMAKE_UNIQUE_ASSERT_NAME(){wxUnusedVar(msg);} \
+        }
+#else
+    #define wxCOMPILE_TIME_ASSERT(expr, msg) \
+        struct wxMAKE_UNIQUE_ASSERT_NAME { unsigned int msg: expr; }
+#endif
 
 
 /* for compatibility only, don't use any more, not needed */
index 07f886e973f17968c752b828785bfd3ee2d07fc1..7c7bab4351ea722d28fbd5c5de99a1681ca66938 100644 (file)
     #undef Yield
 #endif
 
-#ifdef __WXMSW__
-    #include "wx/msw/wrapwin.h"
-#endif
-
 // ----------------------------------------------------------------------------
 // constants
 // ----------------------------------------------------------------------------
@@ -247,7 +243,8 @@ private:
     // include windows.h from this public header and we also have to use the
     // union to force the correct (i.e. maximal) alignment
     //
-    // if CRITICAL_SECTION size changes in Windows, you'll get an assert below
+    // if CRITICAL_SECTION size changes in Windows, you'll get an assert from
+    // thread.cpp and will need to increase the buffer size
     //
     // finally, we need this typedef instead of declaring m_buffer directly
     // because otherwise the assert mentioned above wouldn't compile with some
@@ -257,10 +254,6 @@ private:
 #else // __WIN32__
     typedef char wxCritSectBuffer[24];
 #endif
-
-wxCOMPILE_TIME_ASSERT( sizeof(CRITICAL_SECTION) <= sizeof(wxCritSectBuffer),
-                       wxCriticalSectionBufferTooSmall );
-
     union
     {
         unsigned long m_dummy1;
index 1fd38e5e255f67ede4bc9f3d72b31d6a59bb3cd9..f32a1f848fe6748109665f352ba31dce392a3b1f 100644 (file)
@@ -1190,8 +1190,9 @@ wxString wxFileName::GetForbiddenChars(wxPathFormat format)
     // Inits to forbidden characters that are common to (almost) all platforms.
     wxString strForbiddenChars = wxT("*?");
 
-    // In case of a new path format
+    // If asserts, wxPathFormat has been changed. In case of a new path format
     // addition, the following code might have to be updated.
+    wxCOMPILE_TIME_ASSERT(wxPATH_MAX == 5, wxPathFormatChanged);
     switch ( GetFormat(format) )
     {
         default :
index 28108588a1218070cb2f4a6690fbd2c4c64c550b..f546bd06b30fbc86abb8574e1c57b5a8cc277b9e 100644 (file)
@@ -275,54 +275,54 @@ wxCursor::wxCursor(const wxString& filename,
     }
 }
 
-// all wxWidgets standard cursors
-static const struct StdCursor
-{
-    // is this a standard Windows cursor?
-    bool isStd;
-
-    // the cursor name or id
-    LPCTSTR name;
-} stdCursors[] =
-{
-    {  true, NULL                        }, // wxCURSOR_NONE
-    {  true, IDC_ARROW                   }, // wxCURSOR_ARROW
-    { false, _T("WXCURSOR_RIGHT_ARROW")  }, // wxCURSOR_RIGHT_ARROW
-    { false, _T("WXCURSOR_BULLSEYE")     }, // wxCURSOR_BULLSEYE
-    {  true, IDC_ARROW                   }, // WXCURSOR_CHAR
-    {  true, IDC_CROSS                   }, // WXCURSOR_CROSS
-    { false, _T("WXCURSOR_HAND")         }, // wxCURSOR_HAND
-    {  true, IDC_IBEAM                   }, // WXCURSOR_IBEAM
-    {  true, IDC_ARROW                   }, // WXCURSOR_LEFT_BUTTON
-    { false, _T("WXCURSOR_MAGNIFIER")    }, // wxCURSOR_MAGNIFIER
-    {  true, IDC_ARROW                   }, // WXCURSOR_MIDDLE_BUTTON
-    {  true, IDC_NO                      }, // WXCURSOR_NO_ENTRY
-    { false, _T("WXCURSOR_PBRUSH")       }, // wxCURSOR_PAINT_BRUSH
-    { false, _T("WXCURSOR_PENCIL")       }, // wxCURSOR_PENCIL
-    { false, _T("WXCURSOR_PLEFT")        }, // wxCURSOR_POINT_LEFT
-    { false, _T("WXCURSOR_PRIGHT")       }, // wxCURSOR_POINT_RIGHT
-    {  true, IDC_HELP                    }, // WXCURSOR_QUESTION_ARROW
-    {  true, IDC_ARROW                   }, // WXCURSOR_RIGHT_BUTTON
-    {  true, IDC_SIZENESW                }, // WXCURSOR_SIZENESW
-    {  true, IDC_SIZENS                  }, // WXCURSOR_SIZENS
-    {  true, IDC_SIZENWSE                }, // WXCURSOR_SIZENWSE
-    {  true, IDC_SIZEWE                  }, // WXCURSOR_SIZEWE
-    {  true, IDC_SIZEALL                 }, // WXCURSOR_SIZING
-    { false, _T("WXCURSOR_PBRUSH")       }, // wxCURSOR_SPRAYCAN
-    {  true, IDC_WAIT                    }, // WXCURSOR_WAIT
-    { false, _T("WXCURSOR_WATCH")        }, // WXCURSOR_WATCH
-    { false, _T("WXCURSOR_BLANK")        }, // wxCURSOR_BLANK
-    {  true, IDC_APPSTARTING             }, // wxCURSOR_ARROWWAIT
-
-    // no entry for wxCURSOR_MAX
-};
-
-wxCOMPILE_TIME_ASSERT( WXSIZEOF(stdCursors) == wxCURSOR_MAX,
-                       CursorsIdArrayMismatch );
-
 // Cursors by stock number
 wxCursor::wxCursor(int idCursor)
 {
+    // all wxWidgets standard cursors
+    static const struct StdCursor
+    {
+        // is this a standard Windows cursor?
+        bool isStd;
+
+        // the cursor name or id
+        LPCTSTR name;
+    } stdCursors[] =
+    {
+        {  true, NULL                        }, // wxCURSOR_NONE
+        {  true, IDC_ARROW                   }, // wxCURSOR_ARROW
+        { false, _T("WXCURSOR_RIGHT_ARROW")  }, // wxCURSOR_RIGHT_ARROW
+        { false, _T("WXCURSOR_BULLSEYE")     }, // wxCURSOR_BULLSEYE
+        {  true, IDC_ARROW                   }, // WXCURSOR_CHAR
+        {  true, IDC_CROSS                   }, // WXCURSOR_CROSS
+        { false, _T("WXCURSOR_HAND")         }, // wxCURSOR_HAND
+        {  true, IDC_IBEAM                   }, // WXCURSOR_IBEAM
+        {  true, IDC_ARROW                   }, // WXCURSOR_LEFT_BUTTON
+        { false, _T("WXCURSOR_MAGNIFIER")    }, // wxCURSOR_MAGNIFIER
+        {  true, IDC_ARROW                   }, // WXCURSOR_MIDDLE_BUTTON
+        {  true, IDC_NO                      }, // WXCURSOR_NO_ENTRY
+        { false, _T("WXCURSOR_PBRUSH")       }, // wxCURSOR_PAINT_BRUSH
+        { false, _T("WXCURSOR_PENCIL")       }, // wxCURSOR_PENCIL
+        { false, _T("WXCURSOR_PLEFT")        }, // wxCURSOR_POINT_LEFT
+        { false, _T("WXCURSOR_PRIGHT")       }, // wxCURSOR_POINT_RIGHT
+        {  true, IDC_HELP                    }, // WXCURSOR_QUESTION_ARROW
+        {  true, IDC_ARROW                   }, // WXCURSOR_RIGHT_BUTTON
+        {  true, IDC_SIZENESW                }, // WXCURSOR_SIZENESW
+        {  true, IDC_SIZENS                  }, // WXCURSOR_SIZENS
+        {  true, IDC_SIZENWSE                }, // WXCURSOR_SIZENWSE
+        {  true, IDC_SIZEWE                  }, // WXCURSOR_SIZEWE
+        {  true, IDC_SIZEALL                 }, // WXCURSOR_SIZING
+        { false, _T("WXCURSOR_PBRUSH")       }, // wxCURSOR_SPRAYCAN
+        {  true, IDC_WAIT                    }, // WXCURSOR_WAIT
+        { false, _T("WXCURSOR_WATCH")        }, // WXCURSOR_WATCH
+        { false, _T("WXCURSOR_BLANK")        }, // wxCURSOR_BLANK
+        {  true, IDC_APPSTARTING             }, // wxCURSOR_ARROWWAIT
+
+        // no entry for wxCURSOR_MAX
+    };
+
+    wxCOMPILE_TIME_ASSERT( WXSIZEOF(stdCursors) == wxCURSOR_MAX,
+                           CursorsIdArrayMismatch );
+
     wxCHECK_RET( idCursor > 0 && (size_t)idCursor < WXSIZEOF(stdCursors),
                  _T("invalid cursor id in wxCursor() ctor") );
 
index 4347b8482002cfc102855ef63c865ef4b8a06198..d933639972a2364658160e649a19fe3eb3aa4e7a 100644 (file)
@@ -113,16 +113,16 @@ public:
         m_pItem = &item;
     }
 
-    // memcpy() in Init() can't work if the struct sizes are different
-    wxCOMPILE_TIME_ASSERT( sizeof(LV_ITEM_OTHER) == sizeof(LV_ITEM_NATIVE),
-                           CodeCantWorkIfDiffSizes);
-
     // init with conversion
     void Init(LV_ITEM_OTHER& item)
     {
         // avoid unnecessary dynamic memory allocation, jjust make m_pItem
         // point to our own m_item
 
+        // memcpy() can't work if the struct sizes are different
+        wxCOMPILE_TIME_ASSERT( sizeof(LV_ITEM_OTHER) == sizeof(LV_ITEM_NATIVE),
+                               CodeCantWorkIfDiffSizes);
+
         memcpy(&m_item, &item, sizeof(LV_ITEM_NATIVE));
 
         // convert text from ANSI to Unicod if necessary
index 54279fb6b4c1e97f4dd1ab93b82e7d57d8f4e5e1..0a1d611ca4c8ecc48d0ba8e3b17afc0888fa180f 100644 (file)
@@ -144,6 +144,9 @@ static bool gs_waitingForThread = false;
 
 wxCriticalSection::wxCriticalSection()
 {
+    wxCOMPILE_TIME_ASSERT( sizeof(CRITICAL_SECTION) <= sizeof(wxCritSectBuffer),
+                           wxCriticalSectionBufferTooSmall );
+
     ::InitializeCriticalSection((CRITICAL_SECTION *)m_buffer);
 }