0
Попытки использовать лямбду определить обработчик событий для элементов управления в рамках WxWidgets:WxWidgets Флажок событие лямбда
wxCheckBox*c=new wxCheckBox(panel,wxID_ANY,"...",wxDefaultPosition,wxDefaultSize);
c->Bind(wxEVT_CHECKBOX,[](wxCommandEvent& event){
wxMessageBox(wxT("This is the message."),wxT("This is the title"),wxICON_INFORMATION);
});
Я получаю эти сообщения об ошибках ниже, жалуясь на подписи? Или мне нужно передать флаги компилятора в GCC, чтобы обеспечить совместимость с lambdas?
E:\bootsi\New folder\test.cpp:61:3: error: no matching function for cal
l to 'wxCheckBox::Bind(const wxEventTypeTag<wxCommandEvent>&, MyFrame::MyFrame(c
onst wxString&, const wxPoint&, const wxSize&)::__lambda0)'
});
^
E:\bootsi\New folder\test.cpp:61:3: note: candidates are:
In file included from D:/build/wxWidgets-3.0.1/include/wx/wx.h:24:0,
from E:\bootsi\New folder\test.cpp:5:
D:/build/wxWidgets-3.0.1/include/wx/event.h:3524:10: note: template<class EventT
ag, class EventArg> void wxEvtHandler::Bind(const EventTag&, void (*)(EventArg&)
, int, int, wxObject*)
void Bind(const EventTag& eventType,
^
D:/build/wxWidgets-3.0.1/include/wx/event.h:3524:10: note: template argument d
eduction/substitution failed:
E:\bootsi\New folder\test.cpp:61:3: note: mismatched types 'void (*)(
EventArg&)' and 'MyFrame::MyFrame(const wxString&, const wxPoint&, const wxSize&
)::__lambda0'
});
^
In file included from D:/build/wxWidgets-3.0.1/include/wx/wx.h:24:0,
from E:\bootsi\New folder\test.cpp:5:
D:/build/wxWidgets-3.0.1/include/wx/event.h:3550:10: note: template<class EventT
ag, class Functor> void wxEvtHandler::Bind(const EventTag&, const Functor&, int,
int, wxObject*)
void Bind(const EventTag& eventType,
^
D:/build/wxWidgets-3.0.1/include/wx/event.h:3550:10: note: template argument d
eduction/substitution failed:
E:\bootsi\New folder\test.cpp: In substitution of 'template<class Event
Tag, class Functor> void wxEvtHandler::Bind(const EventTag&, const Functor&, int
, int, wxObject*) [with EventTag = wxEventTypeTag<wxCommandEvent>; Functor = MyF
rame::MyFrame(const wxString&, const wxPoint&, const wxSize&)::__lambda0]':
E:\bootsi\New folder\test.cpp:61:3: required from here
E:\bootsi\New folder\test.cpp:61:3: error: template argument for 'templ
ate<class EventTag, class Functor> void wxEvtHandler::Bind(const EventTag&, cons
t Functor&, int, int, wxObject*)' uses local type 'MyFrame::MyFrame(const wxStri
ng&, const wxPoint&, const wxSize&)::__lambda0'
});
^
E:\bootsi\New folder\test.cpp:61:3: error: trying to instantiate 'tem
plate<class EventTag, class Functor> void wxEvtHandler::Bind(const EventTag&, co
nst Functor&, int, int, wxObject*)'
In file included from D:/build/wxWidgets-3.0.1/include/wx/wx.h:24:0,
from E:\bootsi\New folder\test.cpp:5:
D:/build/wxWidgets-3.0.1/include/wx/event.h:3579:10: note: template<class EventT
ag, class Class, class EventArg, class EventHandler> void wxEvtHandler::Bind(con
st EventTag&, void (Class::*)(EventArg&), EventHandler*, int, int, wxObject*)
void Bind(const EventTag &eventType,
^
D:/build/wxWidgets-3.0.1/include/wx/event.h:3579:10: note: template argument d
eduction/substitution failed:
E:\bootsi\New folder\test.cpp:61:3: note: mismatched types 'void (Cla
ss::*)(EventArg&)' and 'MyFrame::MyFrame(const wxString&, const wxPoint&, const
wxSize&)::__lambda0'
});
^
CMakeFiles\test.dir\build.make:54: recipe for target 'CMakeFiles/FreshS
ettings.dir/test.cpp.obj' failed
mingw32-make[3]: *** [CMakeFiles/test.dir/test.cpp.obj] Error
1
CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/test.dir/all' fa
iled
mingw32-make[2]: *** [CMakeFiles/test.dir/all] Error 2
CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/test.dir/rule' f
ailed
mingw32-make[1]: *** [CMakeFiles/test.dir/rule] Error 2
Makefile:109: recipe for target 'test' failed
mingw32-make: *** [test] Error 2
Press any key to continue . . .
в случае wxwidgets, где в make-файлах/параметрах я могу установить этот флаг глобально для всего дерева исходных кодов? – aelgoa
Как обычно, устанавливая переменную 'CXXFLAGS' (либо в командной строке configure, либо в командной строке, в зависимости от того, что вы используете). –
Я изменил его в config.gcc, но wx не будет перестроен (ничего не сделать для цели), поскольку он уже построен, хотя я указал другой флаг CFG. Как я могу создать отдельную сборку таким образом? 'D: \ build \ wxWidgets-3.0.1 \ build \ msw> mingw32-make makefile.gcc BUILD = release CFG = C++ 11' – aelgoa