lambda functions in Bind

93 views
Skip to first unread message

Big Muscle

unread,
Jun 12, 2012, 6:48:38 AM6/12/12
to wx-dev
Hello,

if I want use lambda function for event binding, everything works
correctly in Debug build. But when compiling in Release, I get
following error:

wxWidgets\include\wx/event.h(535): error C2512: '`anonymous-
namespace'::<lambda0>' : no appropriate default constructor available

Very simple example of code causing the problem is:

Bind(wxEVT_SIZE, [this](wxSizeEvent& event) { int a = 35; });

Am I doing something wrong or lambda functions are not supported in
Release builds?

Vadim Zeitlin

unread,
Jun 12, 2012, 7:18:37 AM6/12/12
to wx-...@googlegroups.com
On Tue, 12 Jun 2012 03:48:38 -0700 (PDT) Big Muscle wrote:

BM> if I want use lambda function for event binding, everything works
BM> correctly in Debug build. But when compiling in Release, I get
BM> following error:
BM>
BM> wxWidgets\include\wx/event.h(535): error C2512: '`anonymous-
BM> namespace'::<lambda0>' : no appropriate default constructor available
BM>
BM> Very simple example of code causing the problem is:
BM>
BM> Bind(wxEVT_SIZE, [this](wxSizeEvent& event) { int a = 35; });
BM>
BM> Am I doing something wrong or lambda functions are not supported in
BM> Release builds?

Can you try it with g++? My first idea would be that it's a compiler bug
but if it isn't, g++ might give a more useful error message.

Regards,
VZ

Big Muscle

unread,
Jul 10, 2012, 6:06:55 AM7/10/12
to wx-...@googlegroups.com
I'm sorry for being late...

I could not try with another compiler because I don't have it available here. But I noticed that the bug is present in only one of our projects. Others work properly. So, after comparing MSVC project files, I found that it is caused by RTTI being disabled (switch /GR- is used). If I enabled it (switch /GR) then everything works ok.

Reply all
Reply to author
Forward
0 new messages