Patch #1982 2007-05-05 16:59

rhf

Eliminate signed/unsigned compiler warnings
Download
1982-Eliminate_sign.patch (17.4 KB)
Category
Application::Refinement
Status
Rejected
Close date
2007-06-01 16:56
Assigned to
biplab
Index: plugins/codecompletion/ccoptionsprjdlg.cpp
===================================================================
--- plugins/codecompletion/ccoptionsprjdlg.cpp    (revision 3935)
+++ plugins/codecompletion/ccoptionsprjdlg.cpp    (working copy)
@@ -122,7 +122,7 @@
 {
     wxArrayString newpaths;
     wxListBox* control = XRCCTRL(*this, "lstPaths", wxListBox);
-    for (int i = 0; i < control->GetCount(); ++i)
+    for (unsigned i = 0; i < control->GetCount(); ++i)
     {
         newpaths.Add(control->GetString(i));
     }
Index: plugins/codecompletion/insertclassmethoddlg.cpp
===================================================================
--- plugins/codecompletion/insertclassmethoddlg.cpp    (revision 3935)
+++ plugins/codecompletion/insertclassmethoddlg.cpp    (working copy)
@@ -42,7 +42,7 @@
     wxArrayString array;
     const wxCheckListBox* clb = XRCCTRL(*this, "chklstMethods", wxCheckListBox);
 
-    for (int i = 0; i < clb->GetCount(); ++i)
+    for (unsigned i = 0; i < clb->GetCount(); ++i)
     {
         if (clb->IsChecked(i))
         {
Index: plugins/compilergcc/compileroptionsdlg.cpp
===================================================================
--- plugins/compilergcc/compileroptionsdlg.cpp    (revision 3935)
+++ plugins/compilergcc/compileroptionsdlg.cpp    (working copy)
@@ -857,7 +857,7 @@
 
     // linker options and libs
     wxListBox* lstLibs = XRCCTRL(*this, "lstLibs", wxListBox);
-    for (int i = 0; i < lstLibs->GetCount(); ++i)
+    for (unsigned i = 0; i < lstLibs->GetCount(); ++i)
         m_LinkLibs.Add(lstLibs->GetString(i));
 }
 
@@ -1407,7 +1407,7 @@
     if (!base)
         return;
     wxNotebook* nb = XRCCTRL(*this, "nbDirs", wxNotebook);
-    for (int i = 0; i < control->GetCount(); ++i)
+    for (unsigned i = 0; i < control->GetCount(); ++i)
     {
         switch (nb->GetSelection())
         {
@@ -1505,7 +1505,7 @@
                         wxYES | wxNO | wxICON_QUESTION) == wxID_YES)
     {
         // Unset all variables of lstVars
-        for (int i=0; i<lstVars->GetCount(); i++)
+        for (unsigned i=0; i<lstVars->GetCount(); i++)
         {
             wxString key = lstVars->GetString(i).BeforeFirst(_T('=')).Trim(true);
             if (!key.IsEmpty())
@@ -1618,7 +1618,7 @@
         int compilerIdx = m_CurrentCompilerIdx;
         CompilerFactory::RemoveCompiler(CompilerFactory::GetCompiler(compilerIdx));
         cmb->Delete(compilerIdx);
-        while (compilerIdx >= cmb->GetCount())
+        while (compilerIdx >= signed(cmb->GetCount()))
             --compilerIdx;
         cmb->SetSelection(compilerIdx);
         m_CurrentCompilerIdx = compilerIdx;
@@ -1747,7 +1747,7 @@
                                 : reinterpret_cast<CompileOptionsBase*>(m_pProject->GetBuildTarget(sel));
     if (!base)
         return;
-    for (int i = 0; i < lstLibs->GetCount(); ++i)
+    for (unsigned i = 0; i < lstLibs->GetCount(); ++i)
     {
         base->AddLinkLib(lstLibs->GetString(i));
     }
@@ -1854,7 +1854,7 @@
 void CompilerOptionsDlg::OnMoveLibDownClick(wxSpinEvent& /*event*/)
 {
     wxListBox* lstLibs = XRCCTRL(*this, "lstLibs", wxListBox);
-    if (lstLibs->GetSelection() == lstLibs->GetCount() - 1)
+    if (lstLibs->GetSelection() == signed(lstLibs->GetCount()) - 1)
         return;
     int sel = lstLibs->GetSelection();
     wxString lib = lstLibs->GetStringSelection();
@@ -1880,7 +1880,7 @@
 void CompilerOptionsDlg::OnMoveDirDownClick(wxSpinEvent& /*event*/)
 {
     wxListBox* lst = GetDirsListBox();
-    if (!lst || lst->GetSelection() == lst->GetCount() - 1)
+    if (!lst || lst->GetSelection() == signed(lst->GetCount()) - 1)
         return;
     int sel = lst->GetSelection();
     wxString lib = lst->GetStringSelection();
Index: plugins/debuggergdb/debuggeroptionsprjdlg.cpp
===================================================================
--- plugins/debuggergdb/debuggeroptionsprjdlg.cpp    (revision 3935)
+++ plugins/debuggergdb/debuggeroptionsprjdlg.cpp    (working copy)
@@ -124,7 +124,7 @@
     wxListBox* control = XRCCTRL(*this, "lstSearchDirs", wxListBox);
 
     m_OldPaths.Clear();
-    for (int i = 0; i < control->GetCount(); ++i)
+    for (unsigned i = 0; i < control->GetCount(); ++i)
     {
         m_OldPaths.Add(control->GetString(i));
     }
Index: plugins/debuggergdb/editwatchesdlg.cpp
===================================================================
--- plugins/debuggergdb/editwatchesdlg.cpp    (revision 3935)
+++ plugins/debuggergdb/editwatchesdlg.cpp    (working copy)
@@ -93,7 +93,7 @@
     XRCCTRL(*this, "lstWatches", wxListBox)->Delete(sel);
     m_LastSel = -1;
     FillWatches();
-    sel = sel == XRCCTRL(*this, "lstWatches", wxListBox)->GetCount() - 1 ? sel - 1 : sel;
+    sel = sel == signed(XRCCTRL(*this, "lstWatches", wxListBox)->GetCount()) - 1 ? sel - 1 : sel;
     FillRecord(sel);
 }
 
Index: plugins/scriptedwizard/filepathpanel.cpp
===================================================================
--- plugins/
download for full patch...
pauliusz 2007-05-09 06:55

this patch will generate warnings on wx2.6

rhf 2007-05-09 13:13

This is new stuff for me and I want to make sure I understand.

Do you mean that this patch will generate warnings when

(1) compiling wx2.6,

or when

(2) compiling CB with wx2.6.

Note that I did not patch the deprecated functions - only the signed/unsigned compares.

This raises a question that I wanted to ask someone. When I update the CB source code (using SVN), do I need to re-compile wxWidgets after each CB update before re-compiling the CB code?

I guess the real questions is - does the creation of the wxWidgets dll depend on the CB code?

Thanks very much for helping me understand this.

Bob

pauliusz 2007-05-09 21:40

(2) compiling CB with wx2.6

signed/unsigned warnings appeared because there were changes between wx26 and wx28 some functions return types.

for example:

- for (int i = 0; i < control->GetCount(); ++i)

+ for (unsigned i = 0; i < control->GetCount(); ++i)

when you will compile CB with wx26 you will get signed/unsigned warnings, because wx26 control->GetCount() will return int.

pauliusz 2007-05-09 22:39

Good example:

- for (selection = m_Selection+1; selection<clbTargets->GetCount(); ++selection)

+ for (selection = m_Selection + 1; selection < static_cast<int>(clbTargets->GetCount()); ++selection)

biplab 2007-06-01 16:56

A number of files have been updated using casting variable as demonstrated by pauliusz. Thus I'm closing this patch.

This patch can't be applied as it will create warnings with wx 2.6. Thanks for your patch.