{"action":"created","issue":{"url":"https://api.github.com/repos/BOINC/boinc/issues/1515","repository_url":"https://api.github.com/repos/BOINC/boinc","labels_url":"https://api.github.com/repos/BOINC/boinc/issues/1515/labels{/name}","comments_url":"https://api.github.com/repos/BOINC/boinc/issues/1515/comments","events_url":"https://api.github.com/repos/BOINC/boinc/issues/1515/events","html_url":"https://github.com/BOINC/boinc/issues/1515","id":143723597,"number":1515,"title":"Compiler errors on openSUSE due to implicit conversion of strings","user":{"login":"aaronpuchert","id":1453952,"avatar_url":"https://avatars.githubusercontent.com/u/1453952?v=3","gravatar_id":"","url":"https://api.github.com/users/aaronpuchert","html_url":"https://github.com/aaronpuchert","followers_url":"https://api.github.com/users/aaronpuchert/followers","following_url":"https://api.github.com/users/aaronpuchert/following{/other_user}","gists_url":"https://api.github.com/users/aaronpuchert/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronpuchert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronpuchert/subscriptions","organizations_url":"https://api.github.com/users/aaronpuchert/orgs","repos_url":"https://api.github.com/users/aaronpuchert/repos","events_url":"https://api.github.com/users/aaronpuchert/events{/privacy}","received_events_url":"https://api.github.com/users/aaronpuchert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-26T16:08:15Z","updated_at":"2016-03-26T17:12:12Z","closed_at":null,"body":"The BOINC package for openSUSE is currently on version 7.2.42. When I tried to compile a more recent version (7.6.22), there were compiler errors of the sort\r\n\r\n```\r\nBOINCGUIApp.cpp:648:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization [a few times...]\r\n[...]\r\nMainDocument.cpp:584:58: error: no matching function for call to ‘CBOINCBaseFrame::UpdateStatusText(const wxString&)’\r\n             pFrame->UpdateStatusText(_(\"Starting client\"));\r\n                                                          ^\r\nIn file included from MainDocument.cpp:33:0:\r\nBOINCBaseFrame.h:90:25: note: candidate: void CBOINCBaseFrame::UpdateStatusText(const wxChar*)\r\n     inline void         UpdateStatusText( const wxChar* ){}\r\n                         ^\r\nBOINCBaseFrame.h:90:25: note:   no known conversion for argument 1 from ‘const wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nMainDocument.cpp:586:72: error: no matching function for call to ‘CMainDocument::Connect(const wchar_t [10], int&, wxString&, int, int)’\r\n                 Connect(wxT(\"localhost\"), portNum, password, TRUE, TRUE);\r\n                                                                        ^\r\nIn file included from MainDocument.cpp:32:0:\r\nMainDocument.h:136:33: note: candidate: int CMainDocument::Connect(const wxChar*, int, const wxChar*, bool, bool)\r\n     int                         Connect(\r\n                                 ^\r\nMainDocument.h:136:33: note:   no known conversion for argument 3 from ‘wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nMainDocument.cpp:592:63: error: no matching function for call to ‘CBOINCBaseFrame::UpdateStatusText(const wxString&)’\r\n             pFrame->UpdateStatusText(_(\"Connecting to client\"));\r\n                                                               ^\r\nIn file included from MainDocument.cpp:33:0:\r\nBOINCBaseFrame.h:90:25: note: candidate: void CBOINCBaseFrame::UpdateStatusText(const wxChar*)\r\n     inline void         UpdateStatusText( const wxChar* ){}\r\n                         ^\r\nBOINCBaseFrame.h:90:25: note:   no known conversion for argument 1 from ‘const wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\n[...]\r\nViewProjects.cpp:393:54: error: no matching function for call to ‘CAdvancedFrame::UpdateStatusText(const wxString&)’\r\n     pFrame->UpdateStatusText(_(\"Updating project...\"));\r\n                                                      ^\r\nIn file included from ViewProjects.cpp:25:0:\r\nBOINCBaseFrame.h:90:25: note: candidate: void CBOINCBaseFrame::UpdateStatusText(const wxChar*)\r\n     inline void         UpdateStatusText( const wxChar* ){}\r\n                         ^\r\nBOINCBaseFrame.h:90:25: note:   no known conversion for argument 1 from ‘const wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nViewProjects.cpp: In member function ‘void CViewProjects::OnProjectSuspend(wxCommandEvent&)’:\r\nViewProjects.cpp:435:66: error: no matching function for call to ‘CAdvancedFrame::UpdateStatusText(const wxString&)’\r\n                 pFrame->UpdateStatusText(_(\"Resuming project...\"));\r\n                                                                  ^\r\nIn file included from ViewProjects.cpp:25:0:\r\nBOINCBaseFrame.h:90:25: note: candidate: void CBOINCBaseFrame::UpdateStatusText(const wxChar*)\r\n     inline void         UpdateStatusText( const wxChar* ){}\r\n                         ^\r\nBOINCBaseFrame.h:90:25: note:   no known conversion for argument 1 from ‘const wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\n```\r\n\r\nThere are roughly 50 of these errors, all for the same reason: in the header `/usr/include/wx-3.0/wx/string.h`, the implicit conversion of `wxString` to `const char*` is only activated when a certain flag is not set:\r\n\r\n```cpp\r\n    // the first two operators conflict with operators for conversion to\r\n    // std::string and they must be disabled if those conversions are enabled;\r\n    // the next one only makes sense if conversions to char* are also defined\r\n    // and not defining it in STL build also helps us to get more clear error\r\n    // messages for the code which relies on implicit conversion to char* in\r\n    // STL build\r\n#if !wxUSE_STD_STRING_CONV_IN_WXSTRING\r\n    operator const char*() const { return c_str(); }\r\n    operator const wchar_t*() const { return c_str(); }\r\n\r\n    // implicit conversion to untyped pointer for compatibility with previous\r\n    // wxWidgets versions: this is the same as conversion to const char * so it\r\n    // may fail!\r\n    operator const void*() const { return c_str(); }\r\n#endif // !wxUSE_STD_STRING_CONV_IN_WXSTRING\r\n```\r\n\r\nIn the config file `/usr/lib64/wx/include/gtk3-unicode-3.0/wx/setup.h`, one can find the lines\r\n\r\n```cpp\r\n#define wxUSE_STL 1\r\n// ...\r\n#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL\r\n```\r\n\r\nI don't really understand the reasoning, because there should be no conflict between the conversion operators, but the documentation of [wxString](http://docs.wxwidgets.org/trunk/classwx_string.html) contains a note\r\n\r\n> If you built wxWidgets with `wxUSE_STL` set to 1, the implicit conversions to both narrow and wide C strings are disabled and replaced with implicit conversions to `std::string` and `std::wstring`.\r\n\r\nSo here is my question: is BOINC not supposed to be built with `wxUSE_STL=1` or could we fix the issue? Basically, one just needs to add `.c_str()` in all the places where errors occur. I think I would be able to do that. However, if you want to rely on implicit conversion instead, I think I'll write a distribution-specific patch."},"comment":{"url":"https://api.github.com/repos/BOINC/boinc/issues/comments/201894114","html_url":"https://github.com/BOINC/boinc/issues/1515#issuecomment-201894114","issue_url":"https://api.github.com/repos/BOINC/boinc/issues/1515","id":201894114,"user":{"login":"aaronpuchert","id":1453952,"avatar_url":"https://avatars.githubusercontent.com/u/1453952?v=3","gravatar_id":"","url":"https://api.github.com/users/aaronpuchert","html_url":"https://github.com/aaronpuchert","followers_url":"https://api.github.com/users/aaronpuchert/followers","following_url":"https://api.github.com/users/aaronpuchert/following{/other_user}","gists_url":"https://api.github.com/users/aaronpuchert/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronpuchert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronpuchert/subscriptions","organizations_url":"https://api.github.com/users/aaronpuchert/orgs","repos_url":"https://api.github.com/users/aaronpuchert/repos","events_url":"https://api.github.com/users/aaronpuchert/events{/privacy}","received_events_url":"https://api.github.com/users/aaronpuchert/received_events","type":"User","site_admin":false},"created_at":"2016-03-26T17:12:11Z","updated_at":"2016-03-26T17:12:11Z","body":"This solves most of the issues, but three files still don't compile. These are only the errors, there are also warnings which I omitted.\r\n\r\n## MainDocument.cpp\r\n```\r\nMainDocument.cpp: In member function ‘int CMainDocument::OnPoll()’:\r\nMainDocument.cpp:586:72: error: no matching function for call to ‘CMainDocument::Connect(const wchar_t [10], int&, wxString&, int, int)’\r\n                 Connect(wxT(\"localhost\"), portNum, password, TRUE, TRUE);\r\n                                                                        ^\r\nIn file included from MainDocument.cpp:33:0:\r\nMainDocument.h:136:33: note: candidate: int CMainDocument::Connect(const wxChar*, int, const wxChar*, bool, bool)\r\n     int                         Connect(\r\n                                 ^\r\nMainDocument.h:136:33: note:   no known conversion for argument 3 from ‘wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nMainDocument.cpp:592:74: error: no matching function for call to ‘CMainDocument::Connect(wxString&, int&, wxString&, int, bool)’\r\n             Connect(hostName, portNum, password, TRUE, password.IsEmpty());\r\n                                                                          ^\r\nIn file included from MainDocument.cpp:33:0:\r\nMainDocument.h:136:33: note: candidate: int CMainDocument::Connect(const wxChar*, int, const wxChar*, bool, bool)\r\n     int                         Connect(\r\n                                 ^\r\nMainDocument.h:136:33: note:   no known conversion for argument 1 from ‘wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\n```\r\n\r\n## BOINCGUIApp.cpp\r\n```\r\nBOINCGUIApp.cpp: In member function ‘virtual void CBOINCGUIApp::OnInitCmdLine(wxCmdLineParser&)’:\r\nBOINCGUIApp.cpp:655:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization\r\n     };\r\n     ^\r\nBOINCGUIApp.cpp:655:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization\r\nBOINCGUIApp.cpp:655:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization\r\nBOINCGUIApp.cpp:655:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization\r\nBOINCGUIApp.cpp:655:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization\r\nBOINCGUIApp.cpp:655:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization\r\nBOINCGUIApp.cpp:655:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization\r\nBOINCGUIApp.cpp:655:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization\r\nBOINCGUIApp.cpp:655:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization\r\nBOINCGUIApp.cpp:655:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization\r\nBOINCGUIApp.cpp:655:5: error: cannot convert ‘const wxString’ to ‘const char*’ in initialization\r\n```\r\n\r\n## ViewProjects.cpp\r\n```\r\nViewProjects.cpp: In member function ‘void CViewProjects::GetDocStatus(wxInt32, wxString&) const’:\r\nViewProjects.cpp:1136:63: error: no matching function for call to ‘CViewProjects::append_to_status(wxString&, const wxString&) const’\r\n             append_to_status(strBuffer, _(\"Suspended by user\"));\r\n                                                               ^\r\nIn file included from BOINCListCtrl.h:59:0,\r\n                 from ViewProjects.cpp:29:\r\nBOINCBaseView.h:196:29: note: candidate: static void CBOINCBaseView::append_to_status(wxString&, const wxChar*)\r\n     static  void            append_to_status(wxString& existing, const wxChar* additional);\r\n                             ^\r\nBOINCBaseView.h:196:29: note:   no known conversion for argument 2 from ‘const wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nViewProjects.cpp:1139:65: error: no matching function for call to ‘CViewProjects::append_to_status(wxString&, const wxString&) const’\r\n             append_to_status(strBuffer, _(\"Won't get new tasks\"));\r\n                                                                 ^\r\nIn file included from BOINCListCtrl.h:59:0,\r\n                 from ViewProjects.cpp:29:\r\nBOINCBaseView.h:196:29: note: candidate: static void CBOINCBaseView::append_to_status(wxString&, const wxChar*)\r\n     static  void            append_to_status(wxString& existing, const wxChar* additional);\r\n                             ^\r\nBOINCBaseView.h:196:29: note:   no known conversion for argument 2 from ‘const wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nViewProjects.cpp:1142:74: error: no matching function for call to ‘CViewProjects::append_to_status(wxString&, const wxString&) const’\r\n             append_to_status(strBuffer, _(\"Project ended - OK to remove\"));\r\n                                                                          ^\r\nIn file included from BOINCListCtrl.h:59:0,\r\n                 from ViewProjects.cpp:29:\r\nBOINCBaseView.h:196:29: note: candidate: static void CBOINCBaseView::append_to_status(wxString&, const wxChar*)\r\n     static  void            append_to_status(wxString& existing, const wxChar* additional);\r\n                             ^\r\nBOINCBaseView.h:196:29: note:   no known conversion for argument 2 from ‘const wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nViewProjects.cpp:1145:73: error: no matching function for call to ‘CViewProjects::append_to_status(wxString&, const wxString&) const’\r\n             append_to_status(strBuffer, _(\"Will remove when tasks done\"));\r\n                                                                         ^\r\nIn file included from BOINCListCtrl.h:59:0,\r\n                 from ViewProjects.cpp:29:\r\nBOINCBaseView.h:196:29: note: candidate: static void CBOINCBaseView::append_to_status(wxString&, const wxChar*)\r\n     static  void            append_to_status(wxString& existing, const wxChar* additional);\r\n                             ^\r\nBOINCBaseView.h:196:29: note:   no known conversion for argument 2 from ‘const wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nViewProjects.cpp:1148:71: error: no matching function for call to ‘CViewProjects::append_to_status(wxString&, const wxString&) const’\r\n             append_to_status(strBuffer, _(\"Scheduler request pending\"));\r\n                                                                       ^\r\nIn file included from BOINCListCtrl.h:59:0,\r\n                 from ViewProjects.cpp:29:\r\nBOINCBaseView.h:196:29: note: candidate: static void CBOINCBaseView::append_to_status(wxString&, const wxChar*)\r\n     static  void            append_to_status(wxString& existing, const wxChar* additional);\r\n                             ^\r\nBOINCBaseView.h:196:29: note:   no known conversion for argument 2 from ‘const wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nViewProjects.cpp:1151:13: error: no matching function for call to ‘CViewProjects::append_to_status(wxString&, wxString) const’\r\n             );\r\n             ^\r\nIn file included from BOINCListCtrl.h:59:0,\r\n                 from ViewProjects.cpp:29:\r\nBOINCBaseView.h:196:29: note: candidate: static void CBOINCBaseView::append_to_status(wxString&, const wxChar*)\r\n     static  void            append_to_status(wxString& existing, const wxChar* additional);\r\n                             ^\r\nBOINCBaseView.h:196:29: note:   no known conversion for argument 2 from ‘wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nViewProjects.cpp:1154:75: error: no matching function for call to ‘CViewProjects::append_to_status(wxString&, const wxString&) const’\r\n             append_to_status(strBuffer, _(\"Scheduler request in progress\"));\r\n                                                                           ^\r\nIn file included from BOINCListCtrl.h:59:0,\r\n                 from ViewProjects.cpp:29:\r\nBOINCBaseView.h:196:29: note: candidate: static void CBOINCBaseView::append_to_status(wxString&, const wxChar*)\r\n     static  void            append_to_status(wxString& existing, const wxChar* additional);\r\n                             ^\r\nBOINCBaseView.h:196:29: note:   no known conversion for argument 2 from ‘const wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nViewProjects.cpp:1157:72: error: no matching function for call to ‘CViewProjects::append_to_status(wxString&, const wxString&) const’\r\n             append_to_status(strBuffer, _(\"Trickle up message pending\"));\r\n                                                                        ^\r\nIn file included from BOINCListCtrl.h:59:0,\r\n                 from ViewProjects.cpp:29:\r\nBOINCBaseView.h:196:29: note: candidate: static void CBOINCBaseView::append_to_status(wxString&, const wxChar*)\r\n     static  void            append_to_status(wxString& existing, const wxChar* additional);\r\n                             ^\r\nBOINCBaseView.h:196:29: note:   no known conversion for argument 2 from ‘const wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\nViewProjects.cpp:1163:105: error: no matching function for call to ‘CViewProjects::append_to_status(wxString&, wxString) const’\r\n             append_to_status(strBuffer, _(\"Communication deferred\") + wxString(\" \") + tsNextRPC.Format());\r\n                                                                                                         ^\r\nIn file included from BOINCListCtrl.h:59:0,\r\n                 from ViewProjects.cpp:29:\r\nBOINCBaseView.h:196:29: note: candidate: static void CBOINCBaseView::append_to_status(wxString&, const wxChar*)\r\n     static  void            append_to_status(wxString& existing, const wxChar* additional);\r\n                             ^\r\nBOINCBaseView.h:196:29: note:   no known conversion for argument 2 from ‘wxString’ to ‘const wxChar* {aka const wchar_t*}’\r\n```"}}