Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: sethjackson on January 24, 2006, 01:04:21 am

Title: const wxString
Post by: sethjackson on January 24, 2006, 01:04:21 am
Code: cpp
const wxString DESCR = _("Welcome to ") + APP_NAME + _T(" v") + APP_VERSION + _T("!\n") + APP_NAME +
   _(" is a full-featured IDE (Integrated Development Environment) "
     "aiming to make the individual developer (and the development team) "
     "work in a nice programming environment offering everything he/they "
     "would ever need from a program of that kind.\n"
     "Its pluggable architecture allows you, the developer, to add "
     "any kind of functionality to the core program, through the use of "
     "plugins...\n");

I know for a fact that it crashes on APP_NAME..... C::B fails to load with the above code why????
Title: Re: const wxString
Post by: rickg22 on January 24, 2006, 01:06:19 am
I think APP_NAME stopped being a macro and began being a variable.
Title: Re: const wxString
Post by: takeshimiya on January 24, 2006, 01:55:51 am
Yes, someone who changed APP_NAME and their friends to be a variable, forgot to update all the code.

Just do a Find in Files search and you'll notice. :)
Title: Re: const wxString
Post by: 280Z28 on January 24, 2006, 02:25:53 am
Move it to appglobals.cpp
Title: Re: const wxString
Post by: sethjackson on January 24, 2006, 03:08:35 am
That code above is in dlgabout.cpp no way it can go to appglobals.cpp. I want to know why the above code crashes and other code that uses APP_NAME doesn't.....
Title: Re: const wxString
Post by: takeshimiya on January 24, 2006, 03:30:03 am
APP_NAME.c_str() ...................
Title: Re: const wxString
Post by: sethjackson on January 24, 2006, 03:34:20 am
APP_NAME.c_str() ...................

Hmmm...

Code: cpp
const wxString DESCR = _("Welcome to ") + APP_NAME.c_str() + _T(" v") + APP_VERSION.c_str() +
                       _T("!\n") + APP_NAME.c_str() +
   _(" is a full-featured IDE (Integrated Development Environment) "
     "aiming to make the individual developer (and the development team) "
     "work in a nice programming environment offering everything he/they "
     "would ever need from a program of that kind.\n"
     "Its pluggable architecture allows you, the developer, to add "
     "any kind of functionality to the core program, through the use of "
     "plugins...\n");


src\dlgabout.cpp:32: error: invalid operands of types `const wxChar*' and `const wxChar*' to binary `operator+'
Title: Re: const wxString
Post by: takeshimiya on January 24, 2006, 03:46:34 am
Heh, that's true, trying to add pointers to char...  :P

wxString(APP_NAME) would do the trick then :D
Title: Re: const wxString
Post by: sethjackson on January 24, 2006, 03:49:23 am
Heh, that's true, trying to add pointers to char...  :P

wxString(APP_NAME) would do the trick then :D

Alreadey did that. It crashes too.  :P

This doesn't crash

wxString(APP_NAME.c_str()) but I get no text....  :lol:

What is going on???  :?
Title: Re: const wxString
Post by: 280Z28 on January 24, 2006, 05:34:30 am
Move it to appglobals.cpp

It's trying to initialize that variable before APP_NAME is set to anything.

I know, I made this change a few days ago...
Title: Re: const wxString
Post by: thomas on January 24, 2006, 08:31:02 am
Sam is right as far as the problem is concerned. It is a problem of order of initialisation.
But his solution is not good, the variable does not belong into app.cpp oops... appglobals.cpp.
Title: Re: const wxString
Post by: mandrav on January 24, 2006, 08:39:40 am
Move it to appglobals.cpp

See Sam? That's what I was talking about in our PM conversation the other day...

sethjackson, Sam got it right: it's a global creation order problem.
But for heaven's sake don't move it to appglobals!   :shock:
Just move it inside the function where it is used. IIRC it's only used in the constructor.
Title: Re: const wxString
Post by: 280Z28 on January 24, 2006, 08:47:28 am
I renamed it to APP_DESC when I moved it. It seemed reasonable to say that's the description of Code::Blocks, and I put an extern blah blah in appglobals.h.

I'd say it's as relevant in the global scope as APP_NAME is, plus you don't have to worry about going to find it in some dialog code when it's more relevant to the app than it is to that specific dialog. I stand that it should go in appglobals.h/cpp :)
Title: Re: const wxString
Post by: sethjackson on January 24, 2006, 05:50:26 pm
Move it to appglobals.cpp

See Sam? That's what I was talking about in our PM conversation the other day...

sethjackson, Sam got it right: it's a global creation order problem.
But for heaven's sake don't move it to appglobals!   :shock:
Just move it inside the function where it is used. IIRC it's only used in the constructor.

Yeah I won't. I got a PM from thomas about this (sort of)..... I will start coding after lunch.  :D