Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: BlueHazzard on February 08, 2013, 03:23:55 pm

Title: Compiling C::B wxChar wxStringCharType error
Post by: BlueHazzard 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!
Title: Re: Compiling C::B wxChar wxStringCharType error
Post by: oBFusCATed 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.
Title: Re: Compiling C::B wxChar wxStringCharType error
Post by: ollydbg 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? (http://forums.codeblocks.org/index.php/topic,18773.msg132267.html#msg132267)