Author Topic: mb_str() != c_str()  (Read 10185 times)

Offline me22

  • Official tester
  • Multiple posting newcomer
  • ***
  • Posts: 53
    • TA Universe
mb_str() != c_str()
« on: September 02, 2005, 04:40:01 am »
Compiling sdk/projectloader.cpp...
sdk/projectloader.cpp: In member function `int
   ProjectLoader::GetValidCompilerIndex(int, const wxString&)':
sdk/projectloader.cpp:883: warning: cannot pass objects of non-POD type `const
   class wxCharBuffer' through `...'; call will abort at runtime

$ cvs annotate sdk/projectloader.cpp
1.28         (mandrav  01-Sep-05):     wxString msg;
1.28         (mandrav  01-Sep-05):     msg.Printf(_("The specified compiler does not exist.\nPlease select the compiler to use for the %s:"), scope.mb_str());
1.28         (mandrav  01-Sep-05):     proposal = wxGetSingleChoiceIndex(msg, _("Select compiler"), compilers);

Anyways, just a reminder that you use .c_str() with .Printf() -- mb_str() returns a proxy object when you're in Unicode mode.  Not to mention that you should always use _C() instead of explicitly mb_str()ing.

xjluo

  • Guest
Re: mb_str() != c_str()
« Reply #1 on: September 02, 2005, 04:46:40 am »
You are right.

There is another proposal to the developers. Check the descriptions of _(), _T() and wxT() in the wxWidgets manual. Please quote all string constant with wxT().

I have tried compiling an unicode version of CB, there are many errors about initializing wxString variable with ansi string constant.

Offline me22

  • Official tester
  • Multiple posting newcomer
  • ***
  • Posts: 53
    • TA Universe
Re: mb_str() != c_str()
« Reply #2 on: September 02, 2005, 04:50:46 am »
xjluo : Use the CVS HEAD version.  I'm religiously fixing Unicode-related errors in that one.

So rigorously, in fact, that I'm using the Unicode version to develop my own project =)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: mb_str() != c_str()
« Reply #3 on: September 02, 2005, 04:59:54 am »
Anyway, just in case anyone got confused...

With wxString::printf we use c_str because it expects a pointer to wxChar's. The only reason to use mb_str() is because we're doing some interfacing with the outside world, i.e. file I/O or pipes.

xjluo

  • Guest
Re: mb_str() != c_str()
« Reply #4 on: September 02, 2005, 05:00:25 am »
Thanks. I'm testing using CB on Mac OS X. In the CVS version there is a component named wxDockit which does not support Mac OS X.  :(

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: mb_str() != c_str()
« Reply #5 on: September 02, 2005, 08:45:30 pm »
Yes, now I wish there was a way to compile *without* wxdockit. It was a recent addition. Anyway there was a thread around here on compiling on Mac OS X...