CVS HEAD wxString::Format crash

Volker Bartheld dr_versaeg at freenet.de
Fri Sep 22 09:15:34 PDT 2006


Hi!

On Fri, 22 Sep 2006 17:10:22 +0100, wkokke at gmail.com ("Willem Kokke")
wrote :
>this code worked in 2.6.3
>    wxString fun = "FLASH_GetWidth";
>    wxString arg = "";
>    wxString::Format("%s, fun, arg);
>but it crashes in CVS HEAD
>So it seems the last parameter can be a wxString and automatically gets
>converted. but the ones before that do not.

I think that was sheer luck (and probably the way how wxString is
internally represented).

>Does anyone know if this is a bug? or do I just have to add .c_str() in
>hundreds of places in my code?

I wouldn't say it's a bug. The ellipsis operator used in
wxString::Format() IMHO behaves the same as in sprintf(), if you run

std::string s("Hello World");
char sz[100];
sprintf(sz, "%s", s);

you cannot be sure what you get. So either you use .c_str() or cast it
to wxChar - whatever you like better.

2ct,
Volker
__
Mail replies to/an V B A R T H E L D at G M X dot D E






More information about the wx-users mailing list