Author Topic: const wxString  (Read 7485 times)

sethjackson

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

I know for a fact that it crashes on APP_NAME..... C::B fails to load with the above code why????

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: const wxString
« Reply #1 on: January 24, 2006, 01:06:19 am »
I think APP_NAME stopped being a macro and began being a variable.

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: const wxString
« Reply #2 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. :)

Offline 280Z28

  • Regular
  • ***
  • Posts: 397
  • *insert unicode here*
Re: const wxString
« Reply #3 on: January 24, 2006, 02:25:53 am »
Move it to appglobals.cpp
78 280Z, "a few bolt-ons" - 12.71@109.04
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
 Check out The Sam Zone :cool:

sethjackson

  • Guest
Re: const wxString
« Reply #4 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.....

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: const wxString
« Reply #5 on: January 24, 2006, 03:30:03 am »
APP_NAME.c_str() ...................

sethjackson

  • Guest
Re: const wxString
« Reply #6 on: January 24, 2006, 03:34:20 am »
APP_NAME.c_str() ...................

Hmmm...

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

src\dlgabout.cpp:32: error: invalid operands of types `const wxChar*' and `const wxChar*' to binary `operator+'

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: const wxString
« Reply #7 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

sethjackson

  • Guest
Re: const wxString
« Reply #8 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???  :?

Offline 280Z28

  • Regular
  • ***
  • Posts: 397
  • *insert unicode here*
Re: const wxString
« Reply #9 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...
78 280Z, "a few bolt-ons" - 12.71@109.04
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
 Check out The Sam Zone :cool:

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: const wxString
« Reply #10 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.
« Last Edit: January 24, 2006, 08:46:26 am by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: const wxString
« Reply #11 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.
Be patient!
This bug will be fixed soon...

Offline 280Z28

  • Regular
  • ***
  • Posts: 397
  • *insert unicode here*
Re: const wxString
« Reply #12 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 :)
78 280Z, "a few bolt-ons" - 12.71@109.04
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
 Check out The Sam Zone :cool:

sethjackson

  • Guest
Re: const wxString
« Reply #13 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