]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed compilation with CW8 (SF patch 567845) and also added alignment fillers for...
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 20 Jun 2002 22:33:22 +0000 (22:33 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 20 Jun 2002 22:33:22 +0000 (22:33 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15898 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/thread.h
src/msw/thread.cpp

index b8585439beda15375e9581b8d5293042492e7ed0..6c126b9fbd9d4d80dd4291f6a7128efaf026f07e 100644 (file)
@@ -241,11 +241,23 @@ private:
 #elif defined(__WXMSW__)
     // we can't allocate any memory in the ctor, so use placement new -
     // unfortunately, we have to hardcode the sizeof() here because we can't
-    // include windows.h from this public header
+    // 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 from
     // thread.cpp and will need to increase the buffer size
-    char m_buffer[24];
+    //
+    // finally, we need this typedef instead of declaring m_buffer directly
+    // because otherwise the assert mentioned above wouldn't compile with some
+    // compilers (notably CodeWarrior 8)
+    typedef char wxCritSectBuffer[24];
+    union
+    {
+        unsigned long m_dummy1;
+        void *m_dummy2;
+
+        wxCritSectBuffer m_buffer;
+    };
 #else
     // nothing for OS/2
 #endif // Unix/Win32/OS2
index 0f5886b86fa783a752989fe60518eba31907e48a..e839cba462fd5852529f22c00c6afdfda2e83ffe 100644 (file)
@@ -132,7 +132,7 @@ static bool gs_waitingForThread = FALSE;
 
 wxCriticalSection::wxCriticalSection()
 {
-    wxCOMPILE_TIME_ASSERT( sizeof(CRITICAL_SECTION) <= sizeof(m_buffer),
+    wxCOMPILE_TIME_ASSERT( sizeof(CRITICAL_SECTION) <= sizeof(wxCritSectBuffer),
                            wxCriticalSectionBufferTooSmall );
 
     ::InitializeCriticalSection((CRITICAL_SECTION *)m_buffer);