Author Topic: wxSmith Compiling error in Linux  (Read 4650 times)

jhaluska

  • Guest
wxSmith Compiling error in Linux
« on: November 06, 2008, 07:45:04 pm »
I've tried the following:

./configure --with-contrib-plugins=wxsmith
make

And I get the following error while compiling:

Code: [Select]
./wxscoder.cpp: In member function 'bool wxsCoder::ApplyChangesEditor(cbEditor*, const wxString&, const wxString&, wxString&, bool, bool, wxString&)':
./wxscoder.cpp:378: error: no matching function for call to 'wxsCoder::RebuildCode(wxString&, const wxChar*, int, wxString&)'
./wxscoder.h:151: note: candidates are: wxString wxsCoder::RebuildCode(wxString&, const wchar_t*, int, wxString&)
./wxscoder.cpp: In member function 'bool wxsCoder::ApplyChangesString(wxString&, const wxString&, const wxString&, wxString&, bool, bool, bool&, wxString&)':
./wxscoder.cpp:466: error: no matching function for call to 'wxsCoder::RebuildCode(wxString&, const wxChar*, size_t, wxString&)'
./wxscoder.h:151: note: candidates are: wxString wxsCoder::RebuildCode(wxString&, const wchar_t*, int, wxString&)

Anybody encounter this before?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6996
    • My Best Post
Re: wxSmith Compiling error in Linux
« Reply #1 on: November 06, 2008, 08:58:17 pm »
Anybody encounter this before?

No, not seen it when using 2.8 wxWidgets; what version of wxWidgets are you using?
2.8.???.???

Have seen similar problem when using 2.9/trunk wxWidgets; the type of patch I am using shown below.
I change .c_str() to .wx_str() but an wxWidgets expert said it is not a solid fix for all wxWidgets builds, works for me under Windows XP.
Code: [Select]
Index: src/plugins/contrib/wxSmith/wxscoder.cpp
===================================================================
--- src/plugins/contrib/wxSmith/wxscoder.cpp (revision 5297)
+++ src/plugins/contrib/wxSmith/wxscoder.cpp (working copy)
@@ -383,7 +383,7 @@
             ( ch == _T('\t') ) ? _T('\t') : _T(' '));
     }
 
-    Code = RebuildCode(BaseIndentation,Code.c_str(),(int)Code.Length(),EOL);
+    Code = RebuildCode(BaseIndentation,Code.wx_str(),(int)Code.Length(),EOL);
 
     // Fixing up positions to contain or not header / ending sequence
     if ( !CodeHasHeader ) Position += Header.Length();
@@ -478,7 +478,7 @@
             ( ch == _T('\t') ) ? _T('\t') : _T(' '));
     }
 
-    Code = RebuildCode(BaseIndentation,Code.c_str(),Code.Length(),EOL);
+    Code = RebuildCode(BaseIndentation,Code.wx_str(),Code.Length(),EOL);
 
     // Checking if code has really changed
     if ( Content.Mid(0,EndPosition) == Code )

« Last Edit: November 06, 2008, 09:08:51 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

gus38

  • Guest
Re: wxSmith Compiling error in Linux
« Reply #2 on: December 04, 2008, 11:46:03 pm »
I have the same error (with wxwidget 2.8.9 on X64)

I've changed the lines :
Code: [Select]
    Code = RebuildCode(BaseIndentation,Code.c_str(),(int)Code.Length(),EOL);by
Code: [Select]
    Code = RebuildCode(BaseIndentation,(wchar_t*)Code.c_str(),(int)Code.Length(),EOL);
and it works for me

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: wxSmith Compiling error in Linux
« Reply #3 on: December 06, 2008, 07:31:24 pm »
I don't understand the problem since wxString::c_str produces  const wxChar* (http://docs.wxwidgets.org/stable/wx_wxstring.html#wxstringcstr) and the function RebuildCode takes const wxChar* as an argument.

It looks like wxWidgets switches between ANSI / UNICODE modes (????)

And neither the wxString::wx_str() nor the wchar_t* cast is good solution. The first one does not exist in wx 2.8 series, the second is a bad workaround and in worst cases may lead to erasing wxSmith-generated code.

BTW. I don't have any problems on Ubuntu x64, wx 2.8.8

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6996
    • My Best Post
Re: wxSmith Compiling error in Linux
« Reply #4 on: December 06, 2008, 08:09:20 pm »
I don't understand the problem since wxString::c_str produces  const wxChar* (http://docs.wxwidgets.org/stable/wx_wxstring.html#wxstringcstr) and the function RebuildCode takes const wxChar* as an argument.

It looks like wxWidgets switches between ANSI / UNICODE modes (????)

And neither the wxString::wx_str() nor the wchar_t* cast is good solution. The first one does not exist in wx 2.8 series, the second is a bad workaround and in worst cases may lead to erasing wxSmith-generated code.

BTW. I don't have any problems on Ubuntu x64, wx 2.8.8

FYI: IIRC wxString::wx_str() existed in 2.6 wxWidgets, it just was not documented any where I could find.

From 2.6.4 string.h
Code: [Select]
    // identical to c_str(), for wxWin 1.6x compatibility
    const wxChar* wx_str()  const { return c_str(); }
Tim S
« Last Edit: December 06, 2008, 08:15:15 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: wxSmith Compiling error in Linux
« Reply #5 on: December 06, 2008, 10:02:57 pm »
No probs for me on 64bit debian with wxWidgets-2.8.9.

But... the second argument for RebuildCode changed from wchar_t* to wxChar* in revision 4930, that means after revision 8.02 .

I think: if you compile C::B yourself, you should use a more recent version.

sashi

  • Guest
Re: wxSmith Compiling error in Linux
« Reply #6 on: December 26, 2008, 01:19:00 pm »
I had the same problem on my system (FreeBSD) and I solved it by installing the Unicode version of wxWidgets!
After installing Unicode wxWidgets, I configured C::B with the option "--with-wx-config=wxgtk2u-2.8-config".

I'm currently running Code::Blocks 8.02 on FreeBSD 7.0.

Sashi
« Last Edit: December 26, 2008, 01:20:37 pm by sashi »