I am trying wxWidgets ( 2.8 ) on C::B ( 10.5 ), created a new project, setup every thing as shown by many guides / tutorials. When I try to compile, it gives two warnings
- error : redefinition of wxFrame
- error : redefinition of wxApp
in
wxMain.hclass wxFrame : public wxFrame {
//constr
//distor
//few funct
//few static const
//a pointer
};in
wxApp.hclass wxApp : public wxApp {
//OnInit function
};All the code is auto generated, as I am just starting to learn wxWidgets
Isn't it obvious?
Your derived class must not have the same name as the base class. Rename wxFrame to something else and it will be fine.
I guess you'll have to run the wxsmith wizard once again...
Yes I tried that before but there were many more errors, :-[
Now I changed them again
in wxMain.h
class MywxFrame : public wxFrame {
//constr MywxFrame
//distor MywxFrame
//few funct
//few static const
//a pointer
};
in wxMain.cpp
respective changes
in wxApp.h
class MywxApp : public wxApp {
//OnInit function
};
in wxApp.cpp
respective changes
The thing that made it work was changing
BEGIN_EVENT_TABLE(wxFrame, wxFrame){} //error (auto generated code) to BEGIN_EVENT_TABLE(MywxFrame, wxFrame){} //Correct which previously I did was BEGIN_EVENT_TABLE(MywxFrame, MywxFrame){} //error
in wxMain.cpp
So all this implies that the auto generated code has error, how do I correct it, so next time I create a new project and don't have to do all this.
Please explain all the step you take to make a new project.
You've made an error somewhere and this will help us see what you're doing wrong.
Editing the existing project is a bit pointless. You can replace all the references to wxFrame and wxApp in the wxs files created by the wizard.
But this is not needed and creating project should work out of the box.
File > New > Project
wxWidgets
wxWidgets 2.8.x
Project title "wx" <-------------Problem creator :o, caught it, but the template must cater for newbies like me
Auth Name "danishx83"
PrefGUIbuild -> wxSmith, Apptype -> FrameBased
wxWidgets Loc-> $(#wx) = "C:\wxWidgets2.8"
Compiler-> MinGW, Debug = Yes, Release = Yes
wxWidgetsLibSet-> Use DLL = Yes, monolithic = Yes, Unicode = Yes
Misc -> PCH = Yes
Files
wxApp.cpp
wxMain.cpp
wx_pch.h
wxApp.h
wxMain.h
resources.rc
xframe.wxs
@oBFusCATed: Thank You
Quote from: Danishx83 on May 03, 2012, 08:27:22 PM
Project title "wx" <-------------Problem creator :o, caught it, but the template must cater for newbies like me
I don't think so, sorry, but there is no way to check for all possible redefinitions in all toolkit we have wizards for.
the problem is that when I named my project as "wx", it created the class wxFrame for my application and was trying to extend the project wxFrame with base class wxFrame. I think a simple solution to it would be to append a "_" or some char between the project name and object type (Frame, Dialog etc) so that no project name could ever replicate the original base class identifiers.
My limited exposure to the world of coding says that such a change to the templets should be easy and improvement.
Quote from: Danishx83 on May 06, 2012, 07:43:52 PM
the problem is that when I named my project as "wx", it created the class wxFrame for my application and was trying to extend the project wxFrame with base class wxFrame. I think a simple solution to it would be to append a "_" or some char between the project name and object type (Frame, Dialog etc) so that no project name could ever replicate the original base class identifiers.
Doesn't sound like a good solution...