News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Unicode compile error code-completion plugin oktober 4th

Started by David Perfors, October 05, 2005, 04:28:12 PM

Previous topic - Next topic

David Perfors

plugins\codecompletion\/parser/token.h: In function `bool LoadStringFromFile(wxFile*, wxString&)':
plugins\codecompletion\/parser/token.h:128: error: ambiguous overload for 'operator=' in 'str = buf'
C:/Development/wxWidgets/include/wx/string.h:627: note: candidates are: wxString& wxString::operator=(int) <near match>
C:/Development/wxWidgets/include/wx/string.h:847: note:                 wxString& wxString::operator=(wxChar) <near match>
C:/Development/wxWidgets/include/wx/string.h:861: note:                 wxString& wxString::operator=(const wxWCharBuffer&) <near match>
C:/Development/wxWidgets/include/wx/string.h:916: note:                 wxString& wxString::operator=(const wxString&) <near match>

I just report it here, because I don't have a solution for it...
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

mandrav

Hmm, that's strange because this function used to exist in parser.cpp but I moved it (verbatim) in token.h. I haven't edited it in any way.
How come it used to build before and not now?
Any unicode guru to shed some light please?

The line where the error occurs is "str = _U(buf);", where 'str' is a wxString& and 'buf' is a static char[] (_U() is declared in sdk/settings.h)...
Be patient!
This bug will be fixed soon...

rickg22

Maybe you need to include the header with the _U macro in there?

Anyway, I don't like function implementations being put in header files. Mind moving it as it was  pls? :P

David Perfors

the header is there :? so I don't know what is wrong... :cry:

--Edit--
I think I fixed it... at least it compiles again :lol: I post the diff so you can test it you're self, because I am NOT an unicode guru :lol:

Index: src/plugins/codecompletion/parser/token.h
===================================================================
RCS file: /cvsroot/codeblocks/codeblocks/src/plugins/codecompletion/parser/token.h,v
retrieving revision 1.4
diff -u -r1.4 token.h
--- src/plugins/codecompletion/parser/token.h 4 Oct 2005 09:17:22 -0000 1.4
+++ src/plugins/codecompletion/parser/token.h 6 Oct 2005 09:29:22 -0000
@@ -122,7 +122,7 @@
     bool ok = true;
     if (size > 0 && size <= 512)
     {
-        static char buf[513];
+        static wxChar buf[513];
         ok = f->Read(buf, size) == size;
         buf[size] = '\0';
         str = _U(buf);
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

rickg22

I don't think that would work... since wxChar would be now 16 bytes, the 0 would be inserted at an inappropriate location, leaving us with garbage strings. We need to find out exactly what went wrong, or how to convert a char buffer into a wxString.

Hmmm try this:

str = wxString(buf,wxConvUTF8);

mandrav

That's what _U() expands to...
I 'll say it again: this code worked fine. I just moved it to another file and now it doesn't?
Be patient!
This bug will be fixed soon...

David Perfors

Strange, the solution of Rick works.... :? But couldn't the code moved back? What was the reason to move it to here?
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

mandrav

Previously, the cache serialization was done by the parser (which keeps the tokens).
Now each token serializes itself so the functions to read/write from/to file, needed to be moved in the header.
Anyway, merely moving a function around shouldn't make it not-compilable, especially since all the needed headers are #included...
Be patient!
This bug will be fixed soon...

rickg22

Yes, very weird. Maybe because it's included in a header, somehow the macro expansion doesn't work.

David Perfors

Shall I commit the change? or should we look for another solution? (if there is one..)
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

mandrav

I was about to commit it just now.
Well, go ahead and commit it. I 'll run a cvs update in a while...
Be patient!
This bug will be fixed soon...