I want to hear if anyone uses C++ 11 features (e.g. Lambda expressions) with CodeLite in a wxWidgets application and can recommend how I can get going to use the -std=c++0x compiler setting in a wxwidgets application.
I downloaded the version with CodeLite, Mingw and wxWidgets all in one package (v 4.0.5589). It installed fine, and I used the provided project wizard to create a program with a wx Frame app. It compiled and executed fine.
I found info elsewhere on the web that I have to add -std=c++0x as compiler setting to enable the C++11 features on mingw. But when I use that, I get build errors in wx header files. When I remove the compiler setting the build errors are gone and the wx app runs, but obviously the new C++ features are then also disabled.
Here's my code:
Code: Select all
#include "gui.h"
#include <functional> // included fo lambda expr
///////////////////////////////////////////////////////////////////////////
MainFrameBase::MainFrameBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
m_menuBar = new wxMenuBar( 0 );
m_menuFile = new wxMenu();
wxMenuItem* menuFileExit;
menuFileExit = new wxMenuItem( m_menuFile, wxID_EXIT, wxString( _("E&xit") ) + wxT('\t') + wxT("Alt+X"), wxEmptyString, wxITEM_NORMAL );
m_menuFile->Append( menuFileExit );
m_menuBar->Append( m_menuFile, _("&File") );
this->SetMenuBar( m_menuBar );
wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxVERTICAL );
this->SetSizer( mainSizer );
this->Layout();
m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );
this->Centre( wxBOTH );
auto test = [](int n){n+=1;};
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( MainFrameBase::OnCloseFrame ) );
this->Connect( menuFileExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnExitClick ) );
}
g++ -c "c:/cp/CdeLiteHello/HelloWorld/gui.cpp" -std=c++0x -g -Wall -O0 -mthreads -DHAVE_W32API_H -D__WXMSW__ -D__WXDEBUG__ -D_UNICODE -IC:\wxWidgets-2.9.4\lib\gcc_dll\mswud -IC:\wxWidgets-2.9.4\include -DWXUSINGDLL -Wno-ctor-dtor-privacy -pipe -fmessage-length=0 -D__WX__ -o ./Debug/gui.o -I.
In file included from C:\wxWidgets-2.9.4\include/wx/string.h:50:0,
from C:\wxWidgets-2.9.4\include/wx/intl.h:17,
from c:/cp/CdeLiteHello/HelloWorld/gui.h:11,
from c:/cp/CdeLiteHello/HelloWorld/gui.cpp:8:
C:\wxWidgets-2.9.4\include/wx/wxcrtbase.h: In function 'char* wxStrdup(const char*)':
C:\wxWidgets-2.9.4\include/wx/wxcrtbase.h:697:62: error: '_strdup' was not declared in this scope
In file included from C:\wxWidgets-2.9.4\include/wx/intl.h:17:0,
from c:/cp/CdeLiteHello/HelloWorld/gui.h:11,
from c:/cp/CdeLiteHello/HelloWorld/gui.cpp:8:
C:\wxWidgets-2.9.4\include/wx/string.h: In function 'int Stricmp(const char*, const char*)':
C:\wxWidgets-2.9.4\include/wx/string.h:174:31: error: 'strcasecmp' was not declared in this scope
mingw32-make.exe[1]: *** [Debug/gui.o] Error 1