Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Build Code::Blocks with Clang
Alpha:
I tested building Code::Blocks with Clang, and this was required to get it to compile:
--- Code: ---Index: src/plugins/contrib/lib_finder/librariesdlg.cpp
===================================================================
--- src/plugins/contrib/lib_finder/librariesdlg.cpp (revision 8648)
+++ src/plugins/contrib/lib_finder/librariesdlg.cpp (working copy)
@@ -90,10 +90,11 @@
LibrariesDlg::LibrariesDlg(wxWindow* parent, TypedResults& knownLibraries)
: m_KnownLibraries(knownLibraries)
- , m_WorkingCopy(knownLibraries)
, m_SelectedConfig(0)
, m_WhileUpdating(false)
{
+ for (int i = 0; i < rtCount; ++i)
+ m_WorkingCopy[i] = knownLibraries[i];
//(*Initialize(LibrariesDlg)
wxBoxSizer* BoxSizer4;
wxStaticBoxSizer* StaticBoxSizer2;
Index: src/plugins/contrib/profiler/cbprofiler.cpp
===================================================================
--- src/plugins/contrib/profiler/cbprofiler.cpp (revision 8648)
+++ src/plugins/contrib/profiler/cbprofiler.cpp (working copy)
@@ -101,18 +101,18 @@
if (project->GetBuildTargetsCount() > 1)
{
// more than one executable target? ask...
- wxString choices[project->GetBuildTargetsCount()];
+ wxArrayString choices;
wxString active_target = project->GetActiveBuildTarget();
int selected = 0;
for (int i=0; i<project->GetBuildTargetsCount(); ++i)
{
- choices[i] = project->GetBuildTarget(i)->GetTitle();
+ choices.Add(project->GetBuildTarget(i)->GetTitle());
if (choices[i] == active_target)
selected = i;
}
wxSingleChoiceDialog dialog(Manager::Get()->GetAppWindow(),
_("Select the target you want to profile"),
- _("Select Target"),project->GetBuildTargetsCount(),choices);
+ _("Select Target"), choices);
dialog.SetSelection(selected);
if (dialog.ShowModal() != wxID_OK)
return -1;
Index: src/sdk/wxscintilla/src/PlatWX.cpp
===================================================================
--- src/sdk/wxscintilla/src/PlatWX.cpp (revision 8648)
+++ src/sdk/wxscintilla/src/PlatWX.cpp (working copy)
@@ -301,10 +301,11 @@
/* C::B begin */
// Since Point now has float as x and y, it seems no longer to be interchangeable with wxPoint,
// and the polygon is not drawn, so we convert it explicitely
- wxPoint points[npts];
+ wxPoint* points = new wxPoint[npts];
for (int i = 0; i < npts; ++i)
points[i] = wxPoint(pts[i].x, pts[i].y);
hDC->DrawPolygon(npts, points);
+ delete [] points;
/* C::B end */
}
--- End code ---
These changes are from my inspection of Clang's warnings:
--- Code: ---Index: src/plugins/contrib/dragscroll/dragscrollcfg.cpp
===================================================================
--- src/plugins/contrib/dragscroll/dragscrollcfg.cpp (revision 8648)
+++ src/plugins/contrib/dragscroll/dragscrollcfg.cpp (working copy)
@@ -93,15 +93,13 @@
Sensitivity = new wxSlider( this, wxID_ANY, 8, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_LABELS|wxSL_TOP );
#if wxCHECK_VERSION(2,9,0)
- if ( 1 ) Sensitivity->SetTickFreq(1);
+ Sensitivity->SetTickFreq(1);
#else
- if ( 1 ) Sensitivity->SetTickFreq(1,0);
+ Sensitivity->SetTickFreq(1,0);
#endif
- if ( 1 ) Sensitivity->SetPageSize(1);
- if ( 0 ) Sensitivity->SetLineSize(0);
- if ( 0 ) Sensitivity->SetThumbLength(0);
- if ( 1 ) Sensitivity->SetTick(1);
- if ( 1 ) Sensitivity->SetSelection(1,10);
+ Sensitivity->SetPageSize(1);
+ Sensitivity->SetTick(1);
+ Sensitivity->SetSelection(1,10);
bSizer7->Add( Sensitivity, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 5 );
bSizer7->Add( 0, 0, 1, wxEXPAND, 0 );
@@ -111,15 +109,13 @@
MouseToLineRatio = new wxSlider( this, wxID_ANY, 30, 10, 100, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_LABELS|wxSL_TOP );
#if wxCHECK_VERSION(2,9,0)
- if ( 1 ) MouseToLineRatio->SetTickFreq(10);
+ MouseToLineRatio->SetTickFreq(10);
#else
- if ( 1 ) MouseToLineRatio->SetTickFreq(10,10);
+ MouseToLineRatio->SetTickFreq(10,10);
#endif
- if ( 1 ) MouseToLineRatio->SetPageSize(10);
- if ( 0 ) MouseToLineRatio->SetLineSize(0);
- if ( 0 ) MouseToLineRatio->SetThumbLength(0);
- if ( 1 ) MouseToLineRatio->SetTick(10);
- if ( 1 ) MouseToLineRatio->SetSelection(10,100);
+ MouseToLineRatio->SetPageSize(10);
+ MouseToLineRatio->SetTick(10);
+ MouseToLineRatio->SetSelection(10,100);
bSizer7->Add( MouseToLineRatio, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 5 );
bSizer7->Add( 0, 0, 1, wxEXPAND, 0 );
@@ -130,15 +126,15 @@
MouseContextDelay = new wxSlider( this, wxID_ANY, 50, 10, 500, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_LABELS|wxSL_TOP );
// Above values are: default mil delay, min, max
#if wxCHECK_VERSION(2,9,0)
- if ( 1 ) MouseContextDelay->SetTickFreq(10);
+ MouseContextDelay->SetTickFreq(10);
#else
- if ( 1 ) MouseContextDelay->SetTickFreq(10,10);
+ MouseContextDelay->SetTickFreq(10,10);
#endif
- if ( 1 ) MouseContextDelay->SetPageSize(10);
- if ( 1 ) MouseContextDelay->SetLineSize(10);
- if ( 1 ) MouseContextDelay->SetThumbLength(10);
- if ( 1 ) MouseContextDelay->SetTick(100);
- if ( 1 ) MouseContextDelay->SetSelection(10,500);
+ MouseContextDelay->SetPageSize(10);
+ MouseContextDelay->SetLineSize(10);
+ MouseContextDelay->SetThumbLength(10);
+ MouseContextDelay->SetTick(100);
+ MouseContextDelay->SetSelection(10,500);
bSizer7->Add( MouseContextDelay, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 5 );
bSizer7->Add( 0, 0, 1, wxEXPAND, 0 );
Index: src/plugins/contrib/codesnippets/FileImport.h
===================================================================
--- src/plugins/contrib/codesnippets/FileImport.h (revision 8648)
+++ src/plugins/contrib/codesnippets/FileImport.h (working copy)
@@ -43,7 +43,7 @@
// ::wxCopyFile (filename, (destDir + dirname - rootSrcDir))
//wxPrintf(_T("OnFile[%s] to [%s]\n"), filename.c_str(), ConvertToDestinationPath(filename).c_str());
int rc = ::wxCopyFile (filename, ConvertToDestinationPath (filename));
- if (not rc) ; //wxPrintf(_T("Copy failed for[%s]"), filename.c_str());
+ // if (not rc) wxPrintf(_T("Copy failed for[%s]"), filename.c_str());
return wxDIR_CONTINUE;
}
Index: src/plugins/contrib/ToolsPlus/se_globals.cpp
===================================================================
--- src/plugins/contrib/ToolsPlus/se_globals.cpp (revision 8648)
+++ src/plugins/contrib/ToolsPlus/se_globals.cpp (working copy)
@@ -1,15 +1,15 @@
#include "se_globals.h"
-wxString GetParentDir(const wxString &path)
+/*wxString GetParentDir(const wxString& path)
{
- wxString parent=wxFileName(parent).GetPath(0);
+ wxString parent=wxFileName(path).GetPath(0);
if(path==parent||parent.IsEmpty())
return wxEmptyString;
else
return parent;
}
-bool DirIsChildOf(const wxString &path, const wxString &/*child*/)
+bool DirIsChildOf(const wxString& path, const wxString& child)
{
wxString parent=path;
while(!parent.IsEmpty())
@@ -19,7 +19,7 @@
parent=GetParentDir(parent);
}
return false;
-}
+}*/
bool WildCardListMatch(wxString list, wxString name, bool strip)
{
Index: src/plugins/contrib/ToolsPlus/se_globals.h
===================================================================
--- src/plugins/contrib/ToolsPlus/se_globals.h (revision 8648)
+++ src/plugins/contrib/ToolsPlus/se_globals.h (working copy)
@@ -10,7 +10,7 @@
#include <sdk.h>
#ifndef CB_PRECOMP
#include <wx/filename.h>
-
+
#include <editorbase.h>
#include <editormanager.h>
#include <logmanager.h>
@@ -20,9 +20,9 @@
#include <cbproject.h>
#endif
-wxString GetParentDir(const wxString &path);
+//wxString GetParentDir(const wxString &path);
-bool DirIsChildOf(const wxString &path, const wxString &child);
+//bool DirIsChildOf(const wxString &path, const wxString &child);
bool WildCardListMatch(wxString list, wxString name, bool strip=true);
Index: src/plugins/contrib/keybinder/menuutils.cpp
===================================================================
--- src/plugins/contrib/keybinder/menuutils.cpp (revision 8648)
+++ src/plugins/contrib/keybinder/menuutils.cpp (working copy)
@@ -71,7 +71,7 @@
return id;
}
-namespace
+/*namespace
{
// ----------------------------------------------------------------------------
int FindMenuDuplicateCount(wxMenuBar *p, wxString &str)
@@ -90,7 +90,7 @@
return count;
}
-}
+}*/
// ----------------------------------------------------------------------------
int FindMenuDuplicateItems(wxMenu* pMenu, wxString& rStr, int& rCount)
// ----------------------------------------------------------------------------
Index: src/plugins/contrib/keybinder/menuutils.h
===================================================================
--- src/plugins/contrib/keybinder/menuutils.h (revision 8648)
+++ src/plugins/contrib/keybinder/menuutils.h (working copy)
@@ -30,7 +30,7 @@
//int /*-lf-WXDLLIMPEXP_KEYBINDER*/ wxFindMenuItem(wxMenuBar *, const wxString &strMenuItemName);
int wxFindMenuItem(wxMenuBar *, const wxString &strMenuItemName);
-int FindMenuDuplicateCount(wxMenuBar *p, const wxString &str);
+//int FindMenuDuplicateCount(wxMenuBar *p, const wxString &str);
int FindMenuDuplicateItems(wxMenu* pMenu, wxString& rStr, int& rCount);
wxString GetFullMenuPath(int);
Index: src/plugins/contrib/keybinder/keybinder.cpp
===================================================================
--- src/plugins/contrib/keybinder/keybinder.cpp (revision 8648)
+++ src/plugins/contrib/keybinder/keybinder.cpp (working copy)
@@ -2578,7 +2578,7 @@
// This routine is screwing up unix, and its never called on MSW
// so.. forget it //(pecan 2006/9/23)
return ;
-
+/*
wxString oldname = m_kBinder.GetName();
// on unix, this routine is being entered with oldname == ""
// We're not going to save the blank temp profile anyway
@@ -2594,7 +2594,7 @@
// change the name of the current profile
m_kBinder.SetName(newname);
-
+*/
#if 0
// and the string of the combobox...
int n = m_pKeyProfiles->FindString(oldname);
Index: src/plugins/contrib/HexEditor/FileContentDisk.cpp
===================================================================
--- src/plugins/contrib/HexEditor/FileContentDisk.cpp (revision 8648)
+++ src/plugins/contrib/HexEditor/FileContentDisk.cpp (working copy)
@@ -561,9 +561,9 @@
// (I mean to call this: std::lower_bound( .. , offset, cmp() )
struct cmp
{
- static inline bool f( OffsetT offset, const DataBlock* block1 )
+ static inline bool f( OffsetT offset_, const DataBlock* block1 )
{
- return block1->start > offset;
+ return block1->start > offset_;
}
};
Index: src/plugins/contrib/FileManager/se_globals.cpp
===================================================================
--- src/plugins/contrib/FileManager/se_globals.cpp (revision 8648)
+++ src/plugins/contrib/FileManager/se_globals.cpp (working copy)
@@ -1,15 +1,15 @@
#include "se_globals.h"
-wxString GetParentDir(const wxString &path)
+/*wxString GetParentDir(const wxString& path)
{
- wxString parent=wxFileName(parent).GetPath(0);
+ wxString parent=wxFileName(path).GetPath(0);
if(path==parent||parent.IsEmpty())
return wxEmptyString;
else
return parent;
}
-bool DirIsChildOf(const wxString &path, const wxString &/*child*/)
+bool DirIsChildOf(const wxString& path, const wxString& child)
{
wxString parent=path;
while(!parent.IsEmpty())
@@ -19,7 +19,7 @@
parent=GetParentDir(parent);
}
return false;
-}
+}*/
bool WildCardListMatch(wxString list, wxString name, bool strip)
{
Index: src/plugins/contrib/FileManager/se_globals.h
===================================================================
--- src/plugins/contrib/FileManager/se_globals.h (revision 8648)
+++ src/plugins/contrib/FileManager/se_globals.h (working copy)
@@ -19,9 +19,9 @@
#include <manager.h>
#endif
-wxString GetParentDir(const wxString &path);
+//wxString GetParentDir(const wxString &path);
-bool DirIsChildOf(const wxString &path, const wxString &child);
+//bool DirIsChildOf(const wxString &path, const wxString &child);
bool WildCardListMatch(wxString list, wxString name, bool strip=false);
--- End code ---
This was also warned about, but I do not quite understand the purpose of the function, so I may not have correctly fixed it:
--- Code: ---Index: src/plugins/contrib/headerfixup/helper.cpp
===================================================================
--- src/plugins/contrib/headerfixup/helper.cpp (revision 8648)
+++ src/plugins/contrib/headerfixup/helper.cpp (working copy)
@@ -60,12 +60,12 @@
const wxString& RemainingLine)
{
wxString s_Ch = NextCharInLine;
- if ( !s_Ch.IsSameAs(ThisChar) && !s_Ch.Trim().IsEmpty() )
+ if ( !s_Ch.IsSameAs(ThisChar) && s_Ch.Trim().IsEmpty() )
{
wxString TrimmedLine(RemainingLine);
TrimmedLine.Trim(false);
if ( !TrimmedLine.IsEmpty() )
- wxString s_Ch = TrimmedLine.GetChar(0);
+ s_Ch = TrimmedLine.GetChar(0);
}
if ( s_Ch.IsSameAs(ThisChar) )
--- End code ---
sh (not bash) gives an error without this change:
--- Code: ---Index: src/update
===================================================================
--- src/update (revision 8648)
+++ src/update (working copy)
@@ -6,7 +6,7 @@
LIBEXT="dll"
else
uname_str=$(uname)
- if [ "$uname_str" == "Darwin" ] ; then
+ if [ "$uname_str" = "Darwin" ] ; then
echo Updating Mac / Darwin version.
EXEEXT=""
LIBEXT="dylib"
--- End code ---
oBFusCATed:
Is this under OSX? I'm currently testing building C::B with clang, too.
Gentoo Linux Clang/LLVM 3.1. I've tried building contrib plugins, yet.
But I have some patches to commit to make things a bit better.
Morten, is there a problem with this patch (it is taken straight from wxgtk's trunk)
--- Code: ---Index: src/sdk/wxscintilla/src/PlatWX.cpp
===================================================================
--- src/sdk/wxscintilla/src/PlatWX.cpp (revision 8647)
+++ src/sdk/wxscintilla/src/PlatWX.cpp (working copy)
@@ -298,14 +298,14 @@ void SurfaceImpl::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesire
{
PenColour(fore);
BrushColour(back);
-/* C::B begin */
- // Since Point now has float as x and y, it seems no longer to be interchangeable with wxPoint,
- // and the polygon is not drawn, so we convert it explicitely
- wxPoint points[npts];
- for (int i = 0; i < npts; ++i)
- points[i] = wxPoint(pts[i].x, pts[i].y);
- hDC->DrawPolygon(npts, points);
-/* C::B end */
+ wxPoint *p = new wxPoint[npts];
+
+ for (int i=0; i<npts; i++) {
+ p[i].x = pts[i].x;
+ p[i].y = pts[i].y;
+ }
+ hdc->DrawPolygon(npts, p);
+ delete [] p;
}
void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)
--- End code ---
BTW: Clang is slower on C::B's code than GCC 4.5. I've built only Codeblocks-unix.cbp. The time was 2:10 vs 1:20 on a core2quad.
Alpha:
--- Quote from: oBFusCATed on December 10, 2012, 10:50:04 pm ---Is this under OSX?
--- End quote ---
No; Ubuntu. I got curious, and sudo apt-geted clang 3.0. (I previously attempted to install Clang on Windows, both with precompiled and from source, but only succeeded in getting a headache. Now I decided to try again on Linux.)
--- Quote from: oBFusCATed on December 10, 2012, 10:50:04 pm ---BTW: Clang is slower on C::B's code than GCC 4.5. I've built only Codeblocks-unix.cbp. The time was 2:10 vs 1:20 on a core2quad.
--- End quote ---
On Linux, Clang (for me) has been both slower and produced binaries that are about 30% larger. What I had been testing for was to see if the warning/error messages were really that much better (as they claim).
On Windows, from my experience, both Clang and MSVC compile significantly faster than MinGW (although, I have yet to see if either can successfully build Code::Blocks).
oBFusCATed:
MSVC can't because this
--- Code: ---L"test" L"TEst"
--- End code ---
is unsupported, at least by VC++<=9.
Alpha:
--- Quote from: Alpha on December 10, 2012, 11:07:58 pm ---
--- Quote from: oBFusCATed on December 10, 2012, 10:50:04 pm ---BTW: Clang is slower on C::B's code than GCC 4.5. I've built only Codeblocks-unix.cbp. The time was 2:10 vs 1:20 on a core2quad.
--- End quote ---
On Linux, Clang (for me) has been both slower and [...]
--- End quote ---
Although, of note, my comparison is not exactly fair; GCC was with PCH, and Clang without (I still need read more documentation to see if I can get Clang to work with PCH).
Navigation
[0] Message Index
[#] Next page
Go to full version