If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
orbitcowboy
I live to help wx-kind
Posts: 178 Joined: Mon Jul 23, 2007 9:01 am
Post
by orbitcowboy » Fri Oct 16, 2009 12:52 pm
Hello,
compiling my code with g++-4.3.3 on Ubuntu linux prints the following compiler warning:
Code: Select all
deprecated conversion from string constant to ‘wxChar*’
The code g++ warns about:
Code: Select all
static wxChar *Cmd[] = {wxT("some text"),NULL};
What i am doing wrong. Or, in other words, how to do it correctly?
Best regards
Orbitcowboy
OS: Ubuntu 9.04 (32/64-Bit), Debian Lenny (32-Bit)
Compiler: gcc/g++-4.3.3 , gcc/g++-4.4.0
wxWidgets: 2.8.10,2.9.0
DavidHart
Site Admin
Posts: 4254 Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK
Post
by DavidHart » Fri Oct 16, 2009 3:29 pm
Hi,
Change to static const wxChar*...
Regards,
David
orbitcowboy
I live to help wx-kind
Posts: 178 Joined: Mon Jul 23, 2007 9:01 am
Post
by orbitcowboy » Fri Oct 16, 2009 3:59 pm
DavidHart wrote: Hi,
Change to static const wxChar*...
Regards,
David
Thank you, this works (the compiler warning is gone). But now i have another (strange) problem with wxExecute (
http://docs.wxwidgets.org/stable/wx_pro ... #wxexecute )
I am using the second version of wxExecute
Code: Select all
long wxExecute(char **argv, int flags = wxEXEC_ASYNC, wxProcess *callback = NULL)
My compiler complains about the static const char *cmd[] = {...} list.
g++ says:
Code: Select all
‘void MyFrame::vDoAsyncExec(const wxString&)’:
../src/Frame.cpp:162: error: call of overloaded ‘wxExecute(const wxChar* [2], <anonymous enum>, wxSSHProcess<MyFrame>*&)’ is ambiguous
/usr/local/include/wx-2.8/wx/utils.h:353: note: candidates are: long int wxExecute(wxChar**, int, wxProcess*) <near match>
/usr/local/include/wx-2.8/wx/utils.h:355: note: long int wxExecute(const wxString&, int, wxProcess*) <near match>
removing the const makes my code compilable, but then the warning appears (see my first post)
What can i do?
Best regards
Orbitcowboy
OS: Ubuntu 9.04 (32/64-Bit), Debian Lenny (32-Bit)
Compiler: gcc/g++-4.3.3 , gcc/g++-4.4.0
wxWidgets: 2.8.10,2.9.0
DavidHart
Site Admin
Posts: 4254 Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK
Post
by DavidHart » Fri Oct 16, 2009 4:50 pm
Why not use a wxString instead? It's much easier.
orbitcowboy
I live to help wx-kind
Posts: 178 Joined: Mon Jul 23, 2007 9:01 am
Post
by orbitcowboy » Fri Oct 16, 2009 7:04 pm
DavidHart wrote: Why not use a wxString instead? It's much easier.
Ok, this is a possibility. But not in my case. I would like to use this special version of wxExecute.
OS: Ubuntu 9.04 (32/64-Bit), Debian Lenny (32-Bit)
Compiler: gcc/g++-4.3.3 , gcc/g++-4.4.0
wxWidgets: 2.8.10,2.9.0
DavidHart
Site Admin
Posts: 4254 Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK
Post
by DavidHart » Fri Oct 16, 2009 8:33 pm
Ok, this is a possibility. But not in my case. I would like to use this special version of wxExecute
Hmm, then either ignore the warning (it's not dangerous, just annoying); or else add wxT("some text") to Cmd[0] dynamically, so you don't need the const (or the static, presumably).
orbitcowboy
I live to help wx-kind
Posts: 178 Joined: Mon Jul 23, 2007 9:01 am
Post
by orbitcowboy » Fri Oct 16, 2009 8:42 pm
DavidHart wrote: Ok, this is a possibility. But not in my case. I would like to use this special version of wxExecute
Hmm, then either ignore the warning (it's not dangerous, just annoying); or else add wxT("some text") to Cmd[0] dynamically, so you don't need the const (or the static, presumably).
Thank you very much for your help!!
Best regards
Orbitcowboy
OS: Ubuntu 9.04 (32/64-Bit), Debian Lenny (32-Bit)
Compiler: gcc/g++-4.3.3 , gcc/g++-4.4.0
wxWidgets: 2.8.10,2.9.0