From 8d7eaf91403705cdd94acaae0d7413e711cce3dc Mon Sep 17 00:00:00 2001 From: Michael Wetherell <mike.wetherell@ntlworld.com> Date: Sun, 12 Feb 2006 12:16:56 +0000 Subject: [PATCH] Warning fixes for VC5 (Igor Korot) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37526 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 44 +++++++++++++++++++++-------------- include/wx/generic/grid.h | 4 ++-- src/common/event.cpp | 2 +- src/common/init.cpp | 2 +- src/common/object.cpp | 2 +- src/common/socket.cpp | 2 +- src/common/wincmn.cpp | 2 +- src/generic/dragimgg.cpp | 2 +- src/generic/fontdlgg.cpp | 2 +- src/generic/grid.cpp | 6 ++--- src/generic/listctrl.cpp | 2 +- src/generic/progdlgg.cpp | 2 +- src/generic/sashwin.cpp | 2 +- src/generic/scrlwing.cpp | 10 ++++---- src/generic/statusbr.cpp | 2 +- src/generic/treectlg.cpp | 2 +- src/msw/dcclient.cpp | 4 ++-- src/msw/dialup.cpp | 2 +- src/msw/dragimag.cpp | 2 +- src/msw/ownerdrw.cpp | 6 ++--- src/msw/tbar95.cpp | 2 +- src/msw/thread.cpp | 2 +- src/msw/window.cpp | 2 +- src/richtext/richtextctrl.cpp | 4 ++-- src/univ/radiobox.cpp | 2 +- 25 files changed, 61 insertions(+), 53 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index a15d8de78c..ade8f25bc9 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -73,6 +73,12 @@ # pragma warning(disable:4512) /* operator=() couldn't be generated */ # pragma warning(disable:4710) /* function not inlined */ + /* For VC++ 5.0 for release mode, the warning 'C4702: unreachable code */ + /* is buggy, and occurs for code that does actually get executed */ +# if !defined __WXDEBUG__ && __VISUALC__ <= 1100 +# pragma warning(disable:4702) /* unreachable code */ +# endif + /* Deprecated functions such as sprintf, localtime */ #if __VISUALC__ >= 1400 #define _CRT_SECURE_NO_DEPRECATE 1 @@ -895,40 +901,42 @@ inline wxUIntPtr wxPtrToUInt(const void *p) explicit with /Wp64 option, suppress them as we really know what we're doing here. Same thing with icc with -Wall. */ -#if defined(__VISUALC__) || defined(__INTELC__) - #pragma warning(push) - #ifdef __VISUALC__ - /* pointer truncation from '' to '' */ - #pragma warning(disable: 4311) - #elif defined(__INTELC__) - /* conversion from pointer to same-sized integral type */ - #pragma warning(disable: 1684) +#ifdef __VISUALC__ + #if __VISUALC__ >= 1200 + #pragma warning(push) #endif + /* pointer truncation from '' to '' */ + #pragma warning(disable: 4311) +#elif defined(__INTELC__) + #pragma warning(push) + /* conversion from pointer to same-sized integral type */ + #pragma warning(disable: 1684) #endif return wx_reinterpret_cast(wxUIntPtr, p); -#if defined(__VISUALC__) || defined(__INTELC__) +#if (defined(__VISUALC__) && __VISUALC__ >= 1200) || defined(__INTELC__) #pragma warning(pop) #endif } inline void *wxUIntToPtr(wxUIntPtr p) { -#if defined(__VISUALC__) || defined(__INTELC__) - #pragma warning(push) - #ifdef __VISUALC__ - /* conversion to type of greater size */ - #pragma warning(disable: 4312) - #elif defined(__INTELC__) - /* invalid type conversion: "wxUIntPtr={unsigned long}" to "void *" */ - #pragma warning(disable: 171) +#ifdef __VISUALC__ + #if __VISUALC__ >= 1200 + #pragma warning(push) #endif + /* conversion to type of greater size */ + #pragma warning(disable: 4312) +#elif defined(__INTELC__) + #pragma warning(push) + /* invalid type conversion: "wxUIntPtr={unsigned long}" to "void *" */ + #pragma warning(disable: 171) #endif return wx_reinterpret_cast(void *, p); -#if defined(__VISUALC__) || defined(__INTELC__) +#if (defined(__VISUALC__) && __VISUALC__ >= 1200) || defined(__INTELC__) #pragma warning(pop) #endif } diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 80156c8239..9b88b90485 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -101,7 +101,7 @@ public: // calling DecRef() once will delete it. Calling IncRef() allows to lock // it until the matching DecRef() is called void IncRef() { m_nRef++; } - void DecRef() { if ( !--m_nRef ) delete this; } + void DecRef() { if ( --m_nRef == 0 ) delete this; } // interpret renderer parameters: arbitrary string whose interpretatin is // left to the derived classes @@ -656,7 +656,7 @@ public: // calling DecRef() once will delete it. Calling IncRef() allows to lock // it until the matching DecRef() is called void IncRef() { m_nRef++; } - void DecRef() { if ( !--m_nRef ) delete this; } + void DecRef() { if ( --m_nRef == 0 ) delete this; } // setters void SetTextColour(const wxColour& colText) { m_colText = colText; } diff --git a/src/common/event.cpp b/src/common/event.cpp index e4401d231f..6da2424443 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -1139,7 +1139,7 @@ void wxEvtHandler::ProcessPendingEvents() wxENTER_CRIT_SECT( Lock() ); - if ( !--n ) + if ( --n == 0 ) break; } diff --git a/src/common/init.cpp b/src/common/init.cpp index 9b87e18152..258539e3ff 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -477,7 +477,7 @@ void wxUninitialize() { wxCRIT_SECT_LOCKER(lockInit, gs_initData.csInit); - if ( !--gs_initData.nInitCount ) + if ( --gs_initData.nInitCount == 0 ) { wxEntryCleanup(); } diff --git a/src/common/object.cpp b/src/common/object.cpp index 78f63ab0a8..87e3dc1ed7 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -310,7 +310,7 @@ void wxObject::UnRef() { wxASSERT_MSG( m_refData->m_count > 0, _T("invalid ref data count") ); - if ( !--m_refData->m_count ) + if ( --m_refData->m_count == 0 ) delete m_refData; m_refData = NULL; } diff --git a/src/common/socket.cpp b/src/common/socket.cpp index a5b9eff86a..4525cfa2d7 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -159,7 +159,7 @@ void wxSocketBase::Shutdown() { // we should be initialized wxASSERT_MSG( m_countInit, _T("extra call to Shutdown()") ); - if ( !--m_countInit ) + if ( --m_countInit == 0 ) { GSocket_Cleanup(); } diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index a884b67788..19ee280fe2 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -1703,7 +1703,7 @@ bool wxWindowBase::Layout() // If there is a sizer, use it instead of the constraints if ( GetSizer() ) { - int w, h; + int w = 0, h = 0; GetVirtualSize(&w, &h); GetSizer()->SetDimension( 0, 0, w, h ); } diff --git a/src/generic/dragimgg.cpp b/src/generic/dragimgg.cpp index 06912f3064..fd104aad66 100644 --- a/src/generic/dragimgg.cpp +++ b/src/generic/dragimgg.cpp @@ -123,7 +123,7 @@ bool wxGenericDragImage::Create(const wxString& str, const wxCursor& cursor) { wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - long w, h; + long w = 0, h = 0; wxScreenDC dc; dc.SetFont(font); dc.GetTextExtent(str, & w, & h); diff --git a/src/generic/fontdlgg.cpp b/src/generic/fontdlgg.cpp index 9476f3e204..61e9a9a30e 100644 --- a/src/generic/fontdlgg.cpp +++ b/src/generic/fontdlgg.cpp @@ -76,7 +76,7 @@ void wxFontPreviewer::OnPaint(wxPaintEvent& WXUNUSED(event)) { dc.SetFont(font); // Calculate vertical centre - long w, h; + long w = 0, h = 0; dc.GetTextExtent( wxT("X"), &w, &h); dc.SetTextForeground(GetForegroundColour()); dc.SetClippingRegion(2, 2, size.x-4, size.y-4); diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index f40295f5f3..e27d34ae3e 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -7484,8 +7484,8 @@ void wxGrid::DrawTextRectangle( wxDC& dc, int vertAlign, int textOrientation ) { - long textWidth, textHeight; - long lineWidth, lineHeight; + long textWidth = 0, textHeight = 0; + long lineWidth = 0, lineHeight = 0; int nLines; dc.SetClippingRegion( rect ); @@ -7614,7 +7614,7 @@ void wxGrid::GetTextBoxSize( const wxDC& dc, { long w = 0; long h = 0; - long lineW, lineH; + long lineW = 0, lineH = 0; size_t i; for ( i = 0; i < lines.GetCount(); i++ ) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index a026f0f683..c7821beb30 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -2564,7 +2564,7 @@ void wxListMainWindow::Thaw() { wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen list control?") ); - if ( !--m_freezeCount ) + if ( --m_freezeCount == 0 ) Refresh(); } diff --git a/src/generic/progdlgg.cpp b/src/generic/progdlgg.cpp index e623577737..c261d63be4 100644 --- a/src/generic/progdlgg.cpp +++ b/src/generic/progdlgg.cpp @@ -141,7 +141,7 @@ wxProgressDialog::wxProgressDialog(wxString const &title, wxClientDC dc(this); dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - long widthText; + long widthText = 0; dc.GetTextExtent(message, &widthText, NULL, NULL, NULL, NULL); wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); diff --git a/src/generic/sashwin.cpp b/src/generic/sashwin.cpp index 85b0648bf4..b9e554da14 100644 --- a/src/generic/sashwin.cpp +++ b/src/generic/sashwin.cpp @@ -95,7 +95,7 @@ void wxSashWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) void wxSashWindow::OnMouseEvent(wxMouseEvent& event) { - wxCoord x, y; + wxCoord x = 0, y = 0; event.GetPosition(&x, &y); wxSashEdgePosition sashHit = SashHitTest(x, y); diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index be7802df03..6eff74787a 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -868,7 +868,7 @@ void wxScrollHelper::Scroll( int x_pos, int y_pos ) if (((x_pos == -1) || (x_pos == m_xScrollPosition)) && ((y_pos == -1) || (y_pos == m_yScrollPosition))) return; - int w, h; + int w = 0, h = 0; GetTargetSize(&w, &h); if ((x_pos != -1) && (m_xScrollPixelsPerLine)) @@ -957,7 +957,7 @@ bool wxScrollHelper::ScrollLayout() // If we're the scroll target, take into account the // virtual size and scrolled position of the window. - int x, y, w, h; + int x = 0, y = 0, w = 0, h = 0; CalcScrolledPosition(0,0, &x,&y); m_win->GetVirtualSize(&w, &h); m_win->GetSizer()->SetDimension(x, y, w, h); @@ -1048,9 +1048,9 @@ void wxScrollHelper::HandleOnPaint(wxPaintEvent& WXUNUSED(event)) // this they always have the priority void wxScrollHelper::HandleOnChar(wxKeyEvent& event) { - int stx, sty, // view origin - szx, szy, // view size (total) - clix, cliy; // view size (on screen) + int stx = 0, sty = 0, // view origin + szx = 0, szy = 0, // view size (total) + clix = 0, cliy = 0; // view size (on screen) GetViewStart(&stx, &sty); GetTargetSize(&clix, &cliy); diff --git a/src/generic/statusbr.cpp b/src/generic/statusbr.cpp index e294b18078..5703a62980 100644 --- a/src/generic/statusbr.cpp +++ b/src/generic/statusbr.cpp @@ -232,7 +232,7 @@ void wxStatusBarGeneric::DrawFieldText(wxDC& dc, int i) wxString text(GetStatusText(i)); - long x, y; + long x = 0, y = 0; dc.GetTextExtent(text, &x, &y); diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 2e2650bfed..68e2b73bdb 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -3518,7 +3518,7 @@ void wxGenericTreeCtrl::Thaw() { wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen tree control?") ); - if ( !--m_freezeCount ) + if ( --m_freezeCount == 0 ) { Refresh(); } diff --git a/src/msw/dcclient.cpp b/src/msw/dcclient.cpp index ce86219b75..d318904387 100644 --- a/src/msw/dcclient.cpp +++ b/src/msw/dcclient.cpp @@ -253,7 +253,7 @@ wxPaintDC::~wxPaintDC() wxCHECK_RET( info, wxT("existing DC should have a cache entry") ); - if ( !--info->count ) + if ( --info->count == 0 ) { ::EndPaint(GetHwndOf(m_canvas), &g_paintStruct); @@ -338,7 +338,7 @@ wxPaintDCEx::~wxPaintDCEx() wxCHECK_RET( info, wxT("existing DC should have a cache entry") ); - if ( !--info->count ) + if ( --info->count == 0 ) { RestoreDC((HDC) m_hDC, saveState); ms_cache.RemoveAt(index); diff --git a/src/msw/dialup.cpp b/src/msw/dialup.cpp index 0114b7759e..074b23c6a5 100644 --- a/src/msw/dialup.cpp +++ b/src/msw/dialup.cpp @@ -1188,7 +1188,7 @@ void wxDialUpManagerMSW::DisableAutoCheckOnlineStatus() { wxCHECK_RET( IsOk(), wxT("using uninitialized wxDialUpManager") ); - if ( --m_autoCheckLevel ) + if ( --m_autoCheckLevel != 0 ) { // still checking return; diff --git a/src/msw/dragimag.cpp b/src/msw/dragimag.cpp index 396962f92f..9249d8c35c 100644 --- a/src/msw/dragimag.cpp +++ b/src/msw/dragimag.cpp @@ -208,7 +208,7 @@ bool wxDragImage::Create(const wxString& str, const wxCursor& cursor) { wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - long w, h; + long w = 0, h = 0; wxScreenDC dc; dc.SetFont(font); dc.GetTextExtent(str, & w, & h); diff --git a/src/msw/ownerdrw.cpp b/src/msw/ownerdrw.cpp index 5b3312796e..c7b56a1dbc 100644 --- a/src/msw/ownerdrw.cpp +++ b/src/msw/ownerdrw.cpp @@ -100,12 +100,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxMSWSystemMenuFontModule, wxModule) // a UDT. Will produce errors if applied using infix notation. // // shut it down -#ifdef __VISUALC__ - #if __VISUALC__ <= 1300 +#if defined __VISUALC__ && __VISUALC__ <= 1300 + #if __VISUALC__ >= 1200 #pragma warning(push) - #pragma warning(disable: 4284) #define POP_WARNINGS #endif + #pragma warning(disable: 4284) #endif #include "wx/hashset.h" diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 9015f5cf73..43a159862d 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -1324,7 +1324,7 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event) if ( event.RightDown() ) { // find the tool under the mouse - wxCoord x,y; + wxCoord x = 0, y = 0; event.GetPosition(&x, &y); wxToolBarToolBase *tool = FindToolForPosition(x, y); diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index 602968aca6..30484e2c86 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -925,7 +925,7 @@ bool wxThread::SetConcurrency(size_t WXUNUSED_IN_WINCE(level)) dwProcMask |= bit; // another process added - if ( !--level ) + if ( --level == 0 ) { // and that's enough break; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 5273cbc4d6..7036774173 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1359,7 +1359,7 @@ void wxWindowMSW::Thaw() { wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") ); - if ( !--m_frozenness ) + if ( --m_frozenness == 0 ) { if ( IsShown() ) { diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 5bdad6e584..80d59be6ff 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -703,7 +703,7 @@ bool wxRichTextCtrl::ScrollIntoView(long position, int keyCode) startX = 0; startY = startY * ppuY; - int sx, sy; + int sx = 0, sy = 0; GetVirtualSize(& sx, & sy); sx = 0; if (ppuY != 0) @@ -796,7 +796,7 @@ bool wxRichTextCtrl::IsPositionVisible(long pos) const startX = 0; startY = startY * ppuY; - int sx, sy; + int sx = 0, sy = 0; GetVirtualSize(& sx, & sy); sx = 0; if (ppuY != 0) diff --git a/src/univ/radiobox.cpp b/src/univ/radiobox.cpp index e4038b1a0d..6a23d3d34b 100644 --- a/src/univ/radiobox.cpp +++ b/src/univ/radiobox.cpp @@ -392,7 +392,7 @@ void wxRadioBox::DoSetToolTip(wxToolTip *tooltip) wxSize wxRadioBox::GetMaxButtonSize() const { - int widthMax, heightMax, width, height; + int widthMax, heightMax, width = 0, height = 0; widthMax = heightMax = 0; int count = GetCount(); -- 2.47.2