Author Topic: Compiling C::B wxChar wxStringCharType error  (Read 6269 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2979
Compiling C::B wxChar wxStringCharType error
« on: February 08, 2013, 03:23:55 pm »
Hello,
i'm compiling C::B svn from source with wx2.9.3 unicode build on Linux Mint 12

I get this errors:
Code
/trunk/src/include/logmanager.h|24|error: cannot convert ‘const wxStringCharType* {aka const char*}’ to ‘const wxChar* {aka const wchar_t*}’ in assignment|

for this code:
Code
    inline wxString F(const wxChar* msg, ...)
    {
        va_list arg_list;
        va_start(arg_list, msg);
#if wxCHECK_VERSION(2,9,0) && wxUSE_UNICODE
// in wx >=  2.9 unicode-build (default) we need the %ls here, or the strings get
// cut after the first character
        ::temp_string = msg;
        ::temp_string.Replace(_T("%s"), _T("%ls"));
        msg = ::temp_string.wx_str();
#endif
        ::temp_string = wxString::FormatV(msg, arg_list);
        va_end(arg_list);

        return ::temp_string;
    };

from wx docs:
Code
wxStringCharType is defined to be:

    char when wxUSE_UNICODE==0
    char when wxUSE_UNICODE_WCHAR==0 and wxUSE_UNICODE==1
    wchar_t when wxUSE_UNICODE_WCHAR==1 and wxUSE_UNICODE==1

The wxUSE_UNICODE_WCHAR symbol is defined to 1 when building on Windows while it's defined to 0 when building on Unix, Linux or OS X. (Note that wxUSE_UNICODE_UTF8 symbol is defined as the opposite of wxUSE_UNICODE_WCHAR.)

and for wxChar:
Code

wxChar is defined to be

    char when wxUSE_UNICODE==0
    wchar_t when wxUSE_UNICODE==1 (the default).


so the error looks obvious, if i compile wx under linux with wxUNICODE (what is standart wxVer > 2.9) wxChar is wchar_t and the internal representation for wxString is char. wx_str() returns char*.
Did i have to recompile wx with  wxUSE_UNICODE_WCHAR=1 ?
Is this then UTF-16 ?

thx!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13393
    • Travis build status
Re: Compiling C::B wxChar wxStringCharType error
« Reply #1 on: February 08, 2013, 05:16:49 pm »
i'm compiling C::B svn from source with wx2.9.3 unicode build on Linux Mint 12
Don't use wx2.9 at least if you want to port it to this version of wx, otherwise use wx2.8.
C::B is not fully working on wx2.9 and if you want to use 2.9 use the latest on 2.9.4 or directly from svn.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5358
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Compiling C::B wxChar wxStringCharType error
« Reply #2 on: June 11, 2014, 11:45:13 am »
Hi, BlueHazzard, there are further discussion about this issue, see:
Re: F() function is not thread safe?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.