Warning fixes found under hardest mode of OpenWatcom. Seems clean in Borland, MinGW and DMC.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29736 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2004-10-08 18:49:13 +00:00
parent 3e98bb2a88
commit 5c519b6cf7
10 changed files with 68 additions and 58 deletions

View File

@@ -40,26 +40,27 @@
*/ */
#ifdef __WATCOMC__ #ifdef __WATCOMC__
#define wxPRE_NO_WARNING_SCOPE for(int i=0;i<1;i++) #define wxFOR_ONCE(name) for(int name=0; name<1; name++)
#define wxPOST_NO_WARNING_SCOPE #define wxPRE_NO_WARNING_SCOPE(name) wxFOR_ONCE(wxMAKE_UNIQUE_NAME(name))
#define wxPOST_NO_WARNING_SCOPE(name)
#else #else
#define wxPRE_NO_WARNING_SCOPE do #define wxPRE_NO_WARNING_SCOPE(name) do
#define wxPOST_NO_WARNING_SCOPE while ( 0 ) #define wxPOST_NO_WARNING_SCOPE(name) while ( 0 )
#endif #endif
#define wxCHECKED_DELETE(ptr) \ #define wxCHECKED_DELETE(ptr) \
wxPRE_NO_WARNING_SCOPE \ wxPRE_NO_WARNING_SCOPE(scope_var1) \
{ \ { \
typedef char complete[sizeof(*ptr)]; \ typedef char complete[sizeof(*ptr)]; \
delete ptr; \ delete ptr; \
} wxPOST_NO_WARNING_SCOPE } wxPOST_NO_WARNING_SCOPE(scope_var1)
#define wxCHECKED_DELETE_ARRAY(ptr) \ #define wxCHECKED_DELETE_ARRAY(ptr) \
wxPRE_NO_WARNING_SCOPE \ wxPRE_NO_WARNING_SCOPE(scope_var2) \
{ \ { \
typedef char complete[sizeof(*ptr)]; \ typedef char complete[sizeof(*ptr)]; \
delete [] ptr; \ delete [] ptr; \
} wxPOST_NO_WARNING_SCOPE } wxPOST_NO_WARNING_SCOPE(scope_var2)
/* These scoped pointers are *not* assignable and cannot be used /* These scoped pointers are *not* assignable and cannot be used
within a container. Look for wxDECLARE_SHARED_PTR for this within a container. Look for wxDECLARE_SHARED_PTR for this

View File

@@ -383,7 +383,7 @@ void wxPrintData::ConvertToNative()
//// Orientation //// Orientation
devMode->dmOrientation = m_printOrientation; devMode->dmOrientation = (short)m_printOrientation;
//// Collation //// Collation
@@ -392,7 +392,7 @@ void wxPrintData::ConvertToNative()
//// Number of copies //// Number of copies
devMode->dmCopies = m_printNoCopies; devMode->dmCopies = (short)m_printNoCopies;
devMode->dmFields |= DM_COPIES; devMode->dmFields |= DM_COPIES;
//// Printer name //// Printer name
@@ -418,8 +418,8 @@ void wxPrintData::ConvertToNative()
if (m_paperId == wxPAPER_NONE) if (m_paperId == wxPAPER_NONE)
{ {
// DEVMODE is in tenths of a milimeter // DEVMODE is in tenths of a milimeter
devMode->dmPaperWidth = m_paperSize.x * 10; devMode->dmPaperWidth = (short)(m_paperSize.x * 10);
devMode->dmPaperLength = m_paperSize.y * 10; devMode->dmPaperLength = (short)(m_paperSize.y * 10);
devMode->dmPaperSize = DMPAPER_USER; devMode->dmPaperSize = DMPAPER_USER;
devMode->dmFields |= DM_PAPERWIDTH; devMode->dmFields |= DM_PAPERWIDTH;
devMode->dmFields |= DM_PAPERLENGTH; devMode->dmFields |= DM_PAPERLENGTH;
@@ -431,7 +431,7 @@ void wxPrintData::ConvertToNative()
wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperType(m_paperId); wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperType(m_paperId);
if (paper) if (paper)
{ {
devMode->dmPaperSize = paper->GetPlatformId(); devMode->dmPaperSize = (short)paper->GetPlatformId();
devMode->dmFields |= DM_PAPERSIZE; devMode->dmFields |= DM_PAPERSIZE;
} }
} }
@@ -439,43 +439,43 @@ void wxPrintData::ConvertToNative()
//// Duplex //// Duplex
int duplex; short duplex;
switch (m_duplexMode) switch (m_duplexMode)
{ {
case wxDUPLEX_HORIZONTAL: { case wxDUPLEX_HORIZONTAL:
duplex = DMDUP_HORIZONTAL; break; duplex = DMDUP_HORIZONTAL;
} break;
case wxDUPLEX_VERTICAL: { case wxDUPLEX_VERTICAL:
duplex = DMDUP_VERTICAL; break; duplex = DMDUP_VERTICAL;
} break;
default: default:
case wxDUPLEX_SIMPLEX: { // in fact case wxDUPLEX_SIMPLEX:
duplex = DMDUP_SIMPLEX; break; duplex = DMDUP_SIMPLEX;
} break;
} }
devMode->dmDuplex = duplex; devMode->dmDuplex = duplex;
devMode->dmFields |= DM_DUPLEX; devMode->dmFields |= DM_DUPLEX;
//// Quality //// Quality
int quality; short quality;
switch (m_printQuality) switch (m_printQuality)
{ {
case wxPRINT_QUALITY_MEDIUM: { case wxPRINT_QUALITY_MEDIUM:
quality = DMRES_MEDIUM; break; quality = DMRES_MEDIUM;
} break;
case wxPRINT_QUALITY_LOW: { case wxPRINT_QUALITY_LOW:
quality = DMRES_LOW; break; quality = DMRES_LOW;
} break;
case wxPRINT_QUALITY_DRAFT: { case wxPRINT_QUALITY_DRAFT:
quality = DMRES_DRAFT; break; quality = DMRES_DRAFT;
} break;
case wxPRINT_QUALITY_HIGH: { case wxPRINT_QUALITY_HIGH:
quality = DMRES_HIGH; break; quality = DMRES_HIGH;
} break;
default: { default:
quality = m_printQuality; break; quality = (short)m_printQuality;
} break;
} }
devMode->dmPrintQuality = quality; devMode->dmPrintQuality = quality;
devMode->dmFields |= DM_PRINTQUALITY; devMode->dmFields |= DM_PRINTQUALITY;
@@ -499,7 +499,7 @@ void wxPrintData::ConvertToNative()
case wxPRINTBIN_FORMSOURCE: devMode->dmDefaultSource = DMBIN_FORMSOURCE; break; case wxPRINTBIN_FORMSOURCE: devMode->dmDefaultSource = DMBIN_FORMSOURCE; break;
default: default:
devMode->dmDefaultSource = DMBIN_USER + m_bin - wxPRINTBIN_USER; devMode->dmDefaultSource = (short)(DMBIN_USER + m_bin - wxPRINTBIN_USER);
break; break;
} }

View File

@@ -255,7 +255,7 @@ void wxColourDatabase::Initialize()
static const struct wxColourDesc static const struct wxColourDesc
{ {
const wxChar *name; const wxChar *name;
int r,g,b; unsigned char r,g,b;
} }
wxColourTable[] = wxColourTable[] =
{ {

View File

@@ -178,7 +178,7 @@ void wxFindReplaceDialogImpl::InitString(const wxString& str,
*ppStr = new wxChar[len]; *ppStr = new wxChar[len];
wxStrcpy(*ppStr, str); wxStrcpy(*ppStr, str);
*pLen = len; *pLen = (WORD)len;
} }
void wxFindReplaceDialogImpl::InitFindWhat(const wxString& str) void wxFindReplaceDialogImpl::InitFindWhat(const wxString& str)

View File

@@ -615,7 +615,7 @@ void wxNativeFontInfo::SetFamily(wxFontFamily family)
facename = _T("MS Sans Serif"); facename = _T("MS Sans Serif");
} }
lf.lfPitchAndFamily = DEFAULT_PITCH | ff_family; lf.lfPitchAndFamily = (BYTE)(DEFAULT_PITCH) | ff_family;
if ( !wxStrlen(lf.lfFaceName) ) if ( !wxStrlen(lf.lfFaceName) )
{ {

View File

@@ -817,7 +817,8 @@ void wxMDIChildFrame::DoSetClientSize(int width, int height)
MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)true); MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)true);
wxSizeEvent event(wxSize(width, height), m_windowId); wxSize size(width, height);
wxSizeEvent event(size, m_windowId);
event.SetEventObject( this ); event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} }
@@ -1318,7 +1319,7 @@ void wxMDIChildFrame::OnIdle(wxIdleEvent& event)
{ {
Show(true); Show(true);
} }
// MDI child frames get their WM_SIZE when they're constructed but at this // MDI child frames get their WM_SIZE when they're constructed but at this
// moment they don't have any children yet so all child windows will be // moment they don't have any children yet so all child windows will be
// positioned incorrectly when they are added later - to fix this, we // positioned incorrectly when they are added later - to fix this, we

View File

@@ -200,7 +200,7 @@ bool wxAutomationObject::Invoke(const wxString& member, int action,
excep.pfnDeferredFillIn = NULL; excep.pfnDeferredFillIn = NULL;
hr = ((IDispatch*)m_dispatchPtr)->Invoke(dispIds[0], IID_NULL, LOCALE_SYSTEM_DEFAULT, hr = ((IDispatch*)m_dispatchPtr)->Invoke(dispIds[0], IID_NULL, LOCALE_SYSTEM_DEFAULT,
action, &dispparams, vReturnPtr, &excep, &uiArgErr); (WORD)action, &dispparams, vReturnPtr, &excep, &uiArgErr);
for (i = 0; i < namedArgStringCount; i++) for (i = 0; i < namedArgStringCount; i++)
{ {
@@ -617,7 +617,7 @@ bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant)
wxDateTime date( variant.GetDateTime() ); wxDateTime date( variant.GetDateTime() );
oleVariant.vt = VT_DATE; oleVariant.vt = VT_DATE;
if (!OleDateFromTm(date.GetYear(), date.GetMonth(), date.GetDay(), if (!OleDateFromTm((WORD)date.GetYear(), date.GetMonth(), date.GetDay(),
date.GetHour(), date.GetMinute(), date.GetSecond(), oleVariant.date)) date.GetHour(), date.GetMinute(), date.GetSecond(), oleVariant.date))
return false; return false;
} }
@@ -702,7 +702,12 @@ bool wxConvertOleToVariant(const VARIANTARG& oleVariant, wxVariant& variant)
if (!TmFromOleDate(oleVariant.date, tmTemp)) if (!TmFromOleDate(oleVariant.date, tmTemp))
return false; return false;
wxDateTime date(tmTemp.tm_yday, (wxDateTime::Month) tmTemp.tm_mon, tmTemp.tm_year, tmTemp.tm_hour, tmTemp.tm_min, tmTemp.tm_sec); wxDateTime date((wxDateTime::wxDateTime_t) tmTemp.tm_yday,
(wxDateTime::Month) tmTemp.tm_mon,
tmTemp.tm_year,
(wxDateTime::wxDateTime_t) tmTemp.tm_hour,
(wxDateTime::wxDateTime_t) tmTemp.tm_min,
(wxDateTime::wxDateTime_t) tmTemp.tm_sec);
variant = date; variant = date;
#endif #endif
@@ -1108,7 +1113,7 @@ static void ReleaseVariant(VARIANTARG *pvarg)
VARIANTARG _huge *pvargArray; VARIANTARG _huge *pvargArray;
long lLBound, lUBound, l; long lLBound, lUBound, l;
vt = pvarg->vt & 0xfff; // mask off flags vt = (VARTYPE)(pvarg->vt & 0xfff); // mask off flags
// check if an array. If so, free its contents, then the array itself. // check if an array. If so, free its contents, then the array itself.
if (V_ISARRAY(pvarg)) if (V_ISARRAY(pvarg))

View File

@@ -871,7 +871,7 @@ bool wxToolBar::Realize()
TBBUTTONINFO tbbi; TBBUTTONINFO tbbi;
tbbi.cbSize = sizeof(tbbi); tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_SIZE; tbbi.dwMask = TBIF_SIZE;
tbbi.cx = size.x; tbbi.cx = (WORD)size.x;
if ( !::SendMessage(GetHwnd(), TB_SETBUTTONINFO, if ( !::SendMessage(GetHwnd(), TB_SETBUTTONINFO,
tool->GetId(), (LPARAM)&tbbi) ) tool->GetId(), (LPARAM)&tbbi) )
{ {

View File

@@ -991,8 +991,8 @@ bool wxTextCtrl::EmulateKeyPress(const wxKeyEvent& event)
size_t lenOld = GetValue().length(); size_t lenOld = GetValue().length();
wxUint32 code = event.GetRawKeyCode(); wxUint32 code = event.GetRawKeyCode();
::keybd_event(code, 0, 0 /* key press */, 0); ::keybd_event((BYTE)code, 0, 0 /* key press */, 0);
::keybd_event(code, 0, KEYEVENTF_KEYUP, 0); ::keybd_event((BYTE)code, 0, KEYEVENTF_KEYUP, 0);
// assume that any alphanumeric key changes the total number of characters // assume that any alphanumeric key changes the total number of characters
// in the control - this should work in 99% of cases // in the control - this should work in 99% of cases
@@ -2122,9 +2122,12 @@ bool wxTextCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
case WM_SETCURSOR: case WM_SETCURSOR:
// ok, so it is hardcoded - do we really nee to // ok, so it is hardcoded - do we really nee to
// customize it? // customize it?
::SetCursor(GetHcursorOf(wxCursor(wxCURSOR_HAND))); {
*result = TRUE; wxCursor cur(wxCURSOR_HAND);
break; ::SetCursor(GetHcursorOf(cur));
*result = TRUE;
break;
}
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
@@ -2403,7 +2406,7 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
const wxArrayInt& tabs = style.GetTabs(); const wxArrayInt& tabs = style.GetTabs();
pf.cTabCount = wxMin(tabs.GetCount(), MAX_TAB_STOPS); pf.cTabCount = (SHORT)wxMin(tabs.GetCount(), MAX_TAB_STOPS);
size_t i; size_t i;
for (i = 0; i < (size_t) pf.cTabCount; i++) for (i = 0; i < (size_t) pf.cTabCount; i++)
{ {

View File

@@ -150,7 +150,7 @@ wxTimerProc(HWND WXUNUSED(hwnd),
UINT idTimer, UINT idTimer,
DWORD WXUNUSED(dwTime)) DWORD WXUNUSED(dwTime))
{ {
wxTimerMap::iterator node = g_timerMap.find(idTimer); wxTimerMap::iterator node = g_timerMap.find((unsigned long)idTimer);
wxCHECK_RET( node != g_timerMap.end(), wxT("bogus timer id in wxTimerProc") ); wxCHECK_RET( node != g_timerMap.end(), wxT("bogus timer id in wxTimerProc") );