Author Topic: Unicode compile error code-completion plugin oktober 4th  (Read 9060 times)

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Unicode compile error code-completion plugin oktober 4th
« on: October 05, 2005, 04:28:12 pm »
Code
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

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Unicode compile error code-completion plugin oktober 4th
« Reply #1 on: October 05, 2005, 06:55:11 pm »
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...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Unicode compile error code-completion plugin oktober 4th
« Reply #2 on: October 05, 2005, 06:58:05 pm »
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

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Re: Unicode compile error code-completion plugin oktober 4th
« Reply #3 on: October 06, 2005, 11:14:44 am »
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:

Code
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);
« Last Edit: October 06, 2005, 11:35:35 am by mispunt »
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Unicode compile error code-completion plugin oktober 4th
« Reply #4 on: October 06, 2005, 05:58:22 pm »
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:

Code
str = wxString(buf,wxConvUTF8);
« Last Edit: October 06, 2005, 06:01:20 pm by rickg22 »

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Unicode compile error code-completion plugin oktober 4th
« Reply #5 on: October 06, 2005, 06:19:18 pm »
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...

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Re: Unicode compile error code-completion plugin oktober 4th
« Reply #6 on: October 06, 2005, 07:21:30 pm »
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

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Unicode compile error code-completion plugin oktober 4th
« Reply #7 on: October 06, 2005, 09:49:25 pm »
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...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Unicode compile error code-completion plugin oktober 4th
« Reply #8 on: October 07, 2005, 06:56:56 am »
Yes, very weird. Maybe because it's included in a header, somehow the macro expansion doesn't work.

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Re: Unicode compile error code-completion plugin oktober 4th
« Reply #9 on: October 07, 2005, 09:06:29 am »
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

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Unicode compile error code-completion plugin oktober 4th
« Reply #10 on: October 07, 2005, 09:15:16 am »
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...