For the first time in my life I am trying to build C::B. My setup is Windows 10, current MSYS2/MinGW (including wxWidgets 3.2.2.1) and current nightly C::B build. I started C::B, opened CodeBlocks_wx32_64.cbp (BTW. info in <CB_ROOT>\BUILD is outdated), modified wxWidgets include paths and after some time I got the following strange error(s):
g++.exe -Wall -std=gnu++11 -m64 -g -pipe -mthreads -fmessage-length=0 -fexceptions -Winvalid-pch -DHAVE_W32API_H -D__WXMSW__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DwxUSE_UNICODE -D_WIN64 -Woverloaded-virtual -DEXPORT_LIB -DEXPORT_EVENTS -DWXMAKINGDLL_SCI -iquote.objs32_64\include -I.objs32_64\include -I. -IC:\Tools\MSYS\mingw64\include\wx-3.2 -IC:\Tools\MSYS\mingw64\lib\wx\include\msw-unicode-3.2 -Isdk\wxscintilla\include -Iinclude\tinyxml -Iinclude -Iinclude\tinyxml -Iinclude\scripting\include -Isdk\mozilla_chardet\include -Isdk\mozilla_chardet\include\mfbt -Isdk\mozilla_chardet\include\nsprpub\pr\include -Isdk\mozilla_chardet\include\xpcom -Isdk\mozilla_chardet\include\xpcom\base -Isdk\mozilla_chardet\include\xpcom\glue -Isdk\scripting\bindings -c D:\Works\CodeBlocks\src\sdk\projectloader.cpp -o .objs32_64\sdk\projectloader.o
D:\Works\CodeBlocks\src\sdk\projectloader.cpp: In member function 'bool ProjectLoader::ExportTargetAsProject(const wxString&, const wxString&, TiXmlElement*)':
D:\Works\CodeBlocks\src\sdk\projectloader.cpp:1776:30: error: no matching function for call to 'TiXmlElement::SetAttribute(const char [9], wxString)'
1776 | element->SetAttribute("wildcard", glob.GetWildCard());
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from D:\Works\CodeBlocks\src\include\configmanager.h:15,
from D:\Works\CodeBlocks\src\include\sdk_common.h:121,
from D:\Works\CodeBlocks\src\include\sdk_precomp.h:13:
include\tinyxml/tinyxml.h:1062:14: note: candidate: 'void TiXmlElement::SetAttribute(const char*, const char*)'
1062 | void SetAttribute( const char* name, const char * _value );
| ^~~~~~~~~~~~
include\tinyxml/tinyxml.h:1062:59: note: no known conversion for argument 2 from 'wxString' to 'const char*'
1062 | void SetAttribute( const char* name, const char * _value );
| ~~~~~~~~~~~~~^~~~~~
include\tinyxml/tinyxml.h:1082:14: note: candidate: 'void TiXmlElement::SetAttribute(const char*, int)'
1082 | void SetAttribute( const char * name, int value );
| ^~~~~~~~~~~~
include\tinyxml/tinyxml.h:1082:51: note: no known conversion for argument 2 from 'wxString' to 'int'
1082 | void SetAttribute( const char * name, int value );
| ~~~~^~~~~
D:\Works\CodeBlocks\src\sdk\projectloader.cpp:1778:30: error: no matching function for call to 'TiXmlElement::SetAttribute(const char [3], wxString)'
1778 | element->SetAttribute("id", wxString::Format("%lld", glob.GetId()));
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include\tinyxml/tinyxml.h:1062:14: note: candidate: 'void TiXmlElement::SetAttribute(const char*, const char*)'
1062 | void SetAttribute( const char* name, const char * _value );
| ^~~~~~~~~~~~
include\tinyxml/tinyxml.h:1062:59: note: no known conversion for argument 2 from 'wxString' to 'const char*'
1062 | void SetAttribute( const char* name, const char * _value );
| ~~~~~~~~~~~~~^~~~~~
include\tinyxml/tinyxml.h:1082:14: note: candidate: 'void TiXmlElement::SetAttribute(const char*, int)'
1082 | void SetAttribute( const char * name, int value );
| ^~~~~~~~~~~~
include\tinyxml/tinyxml.h:1082:51: note: no known conversion for argument 2 from 'wxString' to 'int'
1082 | void SetAttribute( const char * name, int value );
| ~~~~^~~~~
The error is "strange" because it is so obvious that I am wondering why it is still there. It looks like the author(s) must have relied on some implicit wxString -> char* conversion. Anyway, mb_str() seems to solve the issue:
--- src/sdk/projectloader.cpp (revision 13254)
+++ src/sdk/projectloader.cpp (working copy)
@@ -1773,9 +1773,9 @@
for (const ProjectGlob& glob : m_pProject->GetGlobs())
{
TiXmlElement *element = AddElement(prjnode, "UnitsGlob", "directory", glob.GetPath());
- element->SetAttribute("wildcard", glob.GetWildCard());
+ element->SetAttribute("wildcard", glob.GetWildCard().mb_str());
element->SetAttribute("recursive", glob.GetRecursive() ? 1 : 0);
- element->SetAttribute("id", wxString::Format("%lld", glob.GetId()));
+ element->SetAttribute("id", wxString::Format("%lld", glob.GetId()).mb_str());
element->SetAttribute("addToProject", glob.GetAddToProject() ? 1 : 0);
const wxArrayString targets = glob.GetTargets();
if (targets.size() > 0)