News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

wxSmith Compiling error in Linux

Started by jhaluska, November 06, 2008, 07:45:04 PM

Previous topic - Next topic

jhaluska

I've tried the following:

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

And I get the following error while compiling:


./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?

stahta01

#1
Quote from: jhaluska on November 06, 2008, 07:45:04 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.

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 )


C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

gus38

I have the same error (with wxwidget 2.8.9 on X64)

I've changed the lines :
    Code = RebuildCode(BaseIndentation,Code.c_str(),(int)Code.Length(),EOL);
by
    Code = RebuildCode(BaseIndentation,(wchar_t*)Code.c_str(),(int)Code.Length(),EOL);

and it works for me

byo

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

stahta01

#4
Quote from: byo 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

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

    // identical to c_str(), for wxWin 1.6x compatibility
    const wxChar* wx_str()  const { return c_str(); }

Tim S
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Jenna

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

#6
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