Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Code completion using LSP and clangd
Grit Clef:
Hi Pecan,
Today I use GCC 14.1 with wx 3.2.5 to build CB, but I suddenly got some errors when building Clangd_client.
--- Code: ---J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp||In member function 'bool Parser::LSP_GetSymbolsByType(json*, std::set<LSP_SymbolKind>&, std::vector<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, LSP_SymbolKind, int> >&)':|
J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp|3667|error: invalid user-defined conversion from 'wxString' to 'char' [-fpermissive]|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: candidate is: 'wxString::operator const wchar_t*() const' (near match)|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: no known conversion from 'const wchar_t*' to 'char'|
W:\SoftwareDevelopmentTools\mingw32\include\c++\14.1.0\bits\basic_string.h|840|note: initializing argument 1 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'|
J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp||In member function 'void Parser::WalkDocumentSymbols(json&, wxString&, int&, std::set<LSP_SymbolKind>&, std::vector<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, LSP_SymbolKind, int> >&)':|
J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp|3879|error: invalid user-defined conversion from 'wxString' to 'char' [-fpermissive]|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: candidate is: 'wxString::operator const wchar_t*() const' (near match)|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: no known conversion from 'const wchar_t*' to 'char'|
W:\SoftwareDevelopmentTools\mingw32\include\c++\14.1.0\bits\basic_string.h|840|note: initializing argument 1 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'|
--- End code ---
How to fix this? Thanks.
Edit: I just changed the 'name' in line 3667 and 3879 in parser.cpp to 'name.c_str()', and errors disappeared.
I find that there are several other errors about the same; I remember that I did some changes in wx/msw/setup.h, maybe they influenced the compatibility of wxString and std::string.
Pecan:
--- Quote from: Grit Clef on June 24, 2024, 07:18:25 am ---Hi Pecan,
Today I use GCC 14.1 with wx 3.2.5 to build CB, but I suddenly got some errors when building Clangd_client.
--- Code: ---J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp||In member function 'bool Parser::LSP_GetSymbolsByType(json*, std::set<LSP_SymbolKind>&, std::vector<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, LSP_SymbolKind, int> >&)':|
J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp|3667|error: invalid user-defined conversion from 'wxString' to 'char' [-fpermissive]|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: candidate is: 'wxString::operator const wchar_t*() const' (near match)|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: no known conversion from 'const wchar_t*' to 'char'|
W:\SoftwareDevelopmentTools\mingw32\include\c++\14.1.0\bits\basic_string.h|840|note: initializing argument 1 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'|
J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp||In member function 'void Parser::WalkDocumentSymbols(json&, wxString&, int&, std::set<LSP_SymbolKind>&, std::vector<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, LSP_SymbolKind, int> >&)':|
J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp|3879|error: invalid user-defined conversion from 'wxString' to 'char' [-fpermissive]|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: candidate is: 'wxString::operator const wchar_t*() const' (near match)|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: no known conversion from 'const wchar_t*' to 'char'|
W:\SoftwareDevelopmentTools\mingw32\include\c++\14.1.0\bits\basic_string.h|840|note: initializing argument 1 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'|
--- End code ---
How to fix this? Thanks.
Edit: I just changed the 'name' in line 3667 and 3879 in parser.cpp to 'name.c_str()', and errors disappeared.
I find that there are several other errors about the same; I remember that I did some changes in wx/msw/setup.h, maybe they influenced the compatibility of wxString and std::string.
--- End quote ---
I am also using mingw 14.1.0. with wxWidgets 3.2.5 (no modifications), but cannot reproduce this error.
Can you give us steps to reproduce the error?
I believe the Nightly is using the same without errors.
Do you get the error using the nightly build?
stahta01:
--- Quote from: Pecan on June 25, 2024, 06:55:35 am ---
--- Quote from: Grit Clef on June 24, 2024, 07:18:25 am ---Hi Pecan,
Today I use GCC 14.1 with wx 3.2.5 to build CB, but I suddenly got some errors when building Clangd_client.
--- Code: ---J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp||In member function 'bool Parser::LSP_GetSymbolsByType(json*, std::set<LSP_SymbolKind>&, std::vector<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, LSP_SymbolKind, int> >&)':|
J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp|3667|error: invalid user-defined conversion from 'wxString' to 'char' [-fpermissive]|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: candidate is: 'wxString::operator const wchar_t*() const' (near match)|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: no known conversion from 'const wchar_t*' to 'char'|
W:\SoftwareDevelopmentTools\mingw32\include\c++\14.1.0\bits\basic_string.h|840|note: initializing argument 1 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'|
J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp||In member function 'void Parser::WalkDocumentSymbols(json&, wxString&, int&, std::set<LSP_SymbolKind>&, std::vector<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, LSP_SymbolKind, int> >&)':|
J:\123\CodeBlocksNightlySrc\codeblocks_sfmirror\src\plugins\contrib\clangd_client\src\codecompletion\parser\parser.cpp|3879|error: invalid user-defined conversion from 'wxString' to 'char' [-fpermissive]|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: candidate is: 'wxString::operator const wchar_t*() const' (near match)|
J:\123\wxWidgets-3.2.5-cb\include\wx\string.h|1635|note: no known conversion from 'const wchar_t*' to 'char'|
W:\SoftwareDevelopmentTools\mingw32\include\c++\14.1.0\bits\basic_string.h|840|note: initializing argument 1 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'|
--- End code ---
How to fix this? Thanks.
Edit: I just changed the 'name' in line 3667 and 3879 in parser.cpp to 'name.c_str()', and errors disappeared.
I find that there are several other errors about the same; I remember that I did some changes in wx/msw/setup.h, maybe they influenced the compatibility of wxString and std::string.
--- End quote ---
I am also using mingw 14.1.0. with wxWidgets 3.2.5 (no modifications), but cannot reproduce this error.
Can you give us steps to reproduce the error?
I believe the Nightly is using the same without errors.
Do you get the error using the nightly build?
--- End quote ---
I would check wxUSE_STL, wxUSE_STD_CONTAINERS_COMPATIBLY, and wxUSE_STD_CONTAINERS values.
And, of course wxUSE_UNICODE should be 1 unless you wish to have a nightmare trying to have it set to 0 and fixing all the problems.
Tim S.
sodev:
--- Quote from: stahta01 on June 25, 2024, 11:46:48 am ---I would check wxUSE_STL, wxUSE_STD_CONTAINERS_COMPATIBLY, and wxUSE_STD_CONTAINERS values.
--- End quote ---
The error message looks like a string conversion error, none of these options affect string conversion.
--- Quote from: stahta01 on June 25, 2024, 11:46:48 am ---And, of course wxUSE_UNICODE should be 1
--- End quote ---
I don't think it is possible to build a current wxWidgets without that, i think i saw that some setup headers forcefully set this define to 1 even if u manually set it to 0.
Either compatibility with previous wxWidgets versions has been disabled or more likely wxUSE_UNSAFE_WXSTRING_CONV was disabled. If it was the latter, it would be a good idea to update the code, because using this automatic conversion can lead to fancy errors.
Grit Clef:
Oh yes, as sodev said, I just disabled wxUSE_UNSAFE_WXSTRING_CONV. Those STL containers related options have been modified, too, but I don't think they really influence the conversion from wxString to std::string.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version