← Back to team overview

kicad-developers team mailing list archive

wxString.c_str()

 

Jean-Pierre & Other Developers,


It is my understanding that on newer versions of wxWidgets, we will not be able to pass wxString.c_str() to the Printf() function of wxString. And wxString.GetData() will not exist.


http://docs.wxwidgets.org/stable/wx_wxstring.html#wxstringcstr


I first discovered this when using wxWidgets 2.9, and this is why I wrote the GetChars( wxString ) function to hide this future migration problem.

Please let me know if I am wrong, otherwise please consider minimizing our pain in the future and look into our macros.h's GetChars() please.


(I do like the wxString.Printf() function. And this is no reason to stop using that.)


So according to my understanding, we are better writing:

wxString s;
wxString formatMe;

s.Printf( wxT("%s"), GetChars( formatMe ) );

than this:

s.Printf( wxT("%s"), formatMe.c_str() );


For 2.9 or 3.0 the c_str() will not work, at least that is my understanding based on a snapshot 5 months ago when I wrote GetChars().


Tootles,

Dick







Follow ups