Page 1 of 1

DEFINE_EVENT_TYPE obsolete?

Posted: Sun Oct 10, 2010 11:40 am
by MoonKid
I am using wx from SVN. In event.h I can read that DEFINE_EVENT_TYPE is obsolete.

What can I use alternatively?

Posted: Sun Oct 10, 2010 12:58 pm
by DavidHart
Hi,

As mentioned in the event overview in 2.9 you may/should use the wxDEFINE_EVENT() macro, which gives Bind() its type-safety.

Regards,

David

Posted: Sun Oct 10, 2010 1:18 pm
by MoonKid
I see but didn't understand the difference. ;)

This is how I fire the event.

Code: Select all

BFMainFrame::Instance()->GetEventHandler()->AddPendingEvent(wxCommandEvent(BF_EVENT_THREAD_END, BF_ID_MAINFRAME));
I tried

Code: Select all

wxDEFINE_EVENT(BF_EVENT_THREAD_END, wxCommandEvent);
But of course it cause in this error message

Code: Select all

1>d:\garage\projekte\blackfisk\trunk\src\bfthread_backuprunner.cpp(32) : error C2371: 'BF_EVENT_THREAD_END': Neudefinition; unterschiedliche Basistypen
because wxCommandEvent is still declared.

How can I solve that? I think I missinterpret the design rule behind it.

Posted: Sun Oct 10, 2010 2:53 pm
by Auria
I don't speak german so I'm not sure what the error message means. I think it could be that you left an old DECLARE_EVENT_TYPE macro around or so

Posted: Mon Oct 11, 2010 6:46 am
by MoonKid
It says

Code: Select all

new definition; different basic types

Posted: Mon Oct 11, 2010 5:16 pm
by Auria
Auria wrote:I think it could be that you left an old DECLARE_EVENT_TYPE macro around or so
I still think this ;)

Posted: Mon Oct 11, 2010 5:35 pm
by MoonKid
I think it could be that you left an old DECLARE_EVENT_TYPE macro around or so
What do you mean exactly?

I can see nothing wrong on my code described below.

Posted: Mon Oct 11, 2010 6:31 pm
by jfouche
You probably left a DECLARE_EVENT_TYPE in a header file.

If you declare your event a way, and define it another way, you'll have this message. So if you need your event to be visible out of the scope of your cpp file, you'll have to define it in the header, using the 2.9 way (eg : wxDECLARE_EVENT instead of DECLARE_EVENT_TYPE) :

Code: Select all

// this is typically in a header: it just declares MY_EVENT event type
wxDECLARE_EVENT(MY_EVENT, wxCommandEvent);

// this is a definition so can't be in a header
wxDEFINE_EVENT(MY_EVENT, wxCommandEvent);

This was not mentioned in "Changes since 2.8"

Posted: Tue Oct 26, 2010 3:01 pm
by rogue
This change was not mentioned on the page

http://docs.wxwidgets.org/2.9.1/overvie ... nce28.html

I have an existence proof that this change breaks the build potentially in eleven of my projects.

Re: This was not mentioned in "Changes since 2.8"

Posted: Tue Oct 26, 2010 3:31 pm
by Auria
rogue wrote:This change was not mentioned on the page

http://docs.wxwidgets.org/2.9.1/overvie ... nce28.html

I have an existence proof that this change breaks the build potentially in eleven of my projects.
this link is not a full list of changes, it is only an overview of new features. For the full list, see http://svn.wxwidgets.org/viewvc/wx/wxWi ... iew=markup

Posted: Wed Oct 27, 2010 9:41 pm
by dlchnr
Auria wrote:I don't speak german ...

Neudefinition; unterschiedliche Basistypen == redefinition; different base types