Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

F() function is not thread safe?

<< < (4/5) > >>

oBFusCATed:
I'd prefer if you start a branch on github or show a patch before committing.
And please name the function SafeF or ThreadedF.

Also why don't you just use wxString::Format it does the same but it is a bit longer to type?

ollydbg:

--- Quote from: oBFusCATed on June 10, 2014, 10:30:10 am ---I'd prefer if you start a branch on github or show a patch before committing.

--- End quote ---
OK, I will show a patch file here later.


--- Quote ---And please name the function SafeF or ThreadedF.

Also why don't you just use wxString::Format it does the same but it is a bit longer to type?

--- End quote ---
Oh, yes, We can use this build-in wxWidgets functions, but I'm not sure it handle the %ls and %s replacement well:

--- Code: ---+#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
+    wxString tmp(msg);
+    tmp.Replace(s, ls);
+    tmp = wxString::FormatV(tmp.wx_str(), arg_list)
+#else
+    wxString tmp(wxString::FormatV(msg, arg_list));
+#endif

--- End code ---
I don't really understand why we need %ls for wx verison >2.9.0.
If we use wxString::Format, what should we use there? %ls or %s ?

oBFusCATed:
Why don't you test it?

ollydbg:

--- Quote from: oBFusCATed on June 11, 2014, 09:36:54 am ---Why don't you test it?

--- End quote ---
Good idea. Before I did some test, I firstly search the Google, and I hit one discussion:
wxChar wxStringCharType error, this link to our forum thread Compiling C::B wxChar wxStringCharType error.

The core reason is: Under Linux, the wx 2.9.0 to 2.9.3 by default use UTF8 as its wxString internal encoding, which is actually char for wxChar, but wx 2.9.4 and wx 3.0.x later switched to wchar_t as its default wxString encoding, so actually wxChar is wchar_t.

See this reply: Re: wxChar wxStringCharType error

--- Quote ---Form the docs:

    const wxStringCharType* wxString::wx_str() const
    Explicit conversion to C string in the internal representation (either wchar_t* or UTF-8-encoded char*, depending on the build).


The wxString internal representation in Unix has been for a long time a char sequence, encoded in UTF8 (as GTK does).
So, you may try to recompile with wxUSE_UNICODE_WCHAR==1.

Anyhow, I know this internal representation has been changed (wx294 or wx-svn, I don't remember) to use wchar_t.
I would try with wx-svn.

--- End quote ---

Under Windows, there is no issue about this, because all the wx unicode build default to wchar_t.

Now, I think C::B won't support build against wx2.9.0 to 2.9.3, so the preprocessor hack should be totally removed.


EDIT, by the way, I can't find official document about %s and %ls, but it looks like I get the answer from this post: Unicode and printf %s formatter - Google Groups, %s is used for a wide string, and %ls is used for wxString.

oBFusCATed:
Then probably place a upper limit to the version check macro or just remove it.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version