Page MenuHomeWildfire Games

Fix Atlas compilation error in wxWidget 3.0.X
AbandonedPublic

Authored by nwtour on Jan 6 2018, 5:00 AM.

Details

Reviewers
vladislavbelov
Summary

Atlas compilation failed. Compilator errors:
AtlasObjectImpl.cpp:167:25: error: call of overloaded ‘add(const char*&, const wxScopedWCharBuffer)’ is ambiguous

note: candidate: void AtObj::add(const char*, const wchar_t*)
note: candidate: void AtObj::add(const char*, const wxString&)

AtlasObjectImpl.cpp:190:25: error: call of overloaded ‘set(const char*&, const wxScopedWCharBuffer)’ is ambiguous

note: candidate: void AtObj::set(const char*, const wchar_t*)
note: candidate: void AtObj::set(const char*, const wxString&)

MapDialog.cpp:184:52: error: no matching function for call to ‘AtlasMessage::qVFSFileExists::qVFSFileExists(const wxScopedWCharBuffer)’

note: candidate: AtlasMessage::qVFSFileExists::qVFSFileExists(std::__cxx11::wstring)

MapDialog.cpp:199:52: error: no matching function for call to ‘AtlasMessage::qVFSFileExists::qVFSFileExists(const wxScopedWCharBuffer)’

note: candidate: AtlasMessage::qVFSFileExists::qVFSFileExists(std::__cxx11::wstring)

ScenarioEditor.cpp:726:52: error: no matching function for call to ‘AtlasMessage::qVFSFileExists::qVFSFileExists(const wxScopedWCharBuffer)'

note: candidate: AtlasMessage::qVFSFileExists::qVFSFileExists(std::__cxx11::wstring)

Description:
On unix system wxWidget.wc_str() polymorphic. If defined wxUSE_UNICODE_UTF8 its wxScopedWCharBuffer and compilator confused.
Patch forced cast to wchar_t and fixed compilation.

Additional info:
http://docs.wxwidgets.org/3.1/classwx_string.html Section Conversion to C string
http://sisyphus.ru/en/srpm/Sisyphus/wxGTK3.1/spec wxWidget build options in my distro.
i386, GNU/Linux 4.9.62, gcc version 5.3.1

Test Plan

Step to reproduce:

  • Compile wxWidget with options -DUNICODE=1 -DwxUSE_UNICODE=1 --enable-utf8=yes
  • Check $ grep 'define wxUSE_UNICODE' /usr/lib/wx/include/gtk3-unicode-3.1/wx/setup.h

#define wxUSE_UNICODE 1
#define wxUSE_UNICODE_UTF8 1

  • Try compile on unix system (failed)

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

nwtour created this revision.Jan 6 2018, 5:00 AM
Vulcan added a subscriber: Vulcan.Jan 6 2018, 5:04 AM

Successful build - Chance fights ever on the side of the prudent.

Updating workspaces...
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...
In D1202#48633, @elexis wrote:

@vladislavbelov are you up for that?

Let's take a look.

@nwtour did you try to compile it with different versions of the wxWidgets?

vladislavbelov requested changes to this revision.Feb 21 2018, 5:36 PM
This revision now requires changes to proceed.Feb 21 2018, 5:36 PM

With wxWidgets-3.1.X version compilation now successfull (linux+gcc)
With wxWidgets-3.0.X version compilation failed

wxWidgets 3.0.5.1 released this on 10 May 2020

Step to reproduce:
wget https://github.com/wxWidgets/wxWidgets/archive/v3.0.5.tar.gz
tar xzvf v3.0.5.tar.gz && cd wxWidgets-3.0.5
./configure --prefix=/usr/local/wxtest --with-gtk=3 --enable-utf8 && make && sudo make install
cd 0AD_DIR
WX_CONFIG=/usr/local/wxtest/bin/wx-config ./build/workspaces/update-workspaces.sh
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/wxtest/lib make -C build/workspaces/gcc

return compilation error

nwtour updated this revision to Diff 16077.Feb 26 2021, 5:42 AM
nwtour retitled this revision from Fix Atlas compilation error if enabled UTF8 in wxWidget to Fix Atlas compilation error in wxWidget 3.0.X.

Update patch for git 0ad

Stan added a subscriber: Stan.Feb 26 2021, 7:36 AM

Did you see D1593? It has a different approach not sure which is better

I'm not sure which code is correct either. Mine is taken from official documentation but looks dirtier

Most importantly, I localized the issue - the problem is not in the compiler, but in the version wxWidget

Currently the patch from https://code.wildfiregames.com/D1593 is not being applied correctly. If the author of D1593 converts the version to git and the version with ToStdWstring () builds successfully from 3.0.5.1 - then my patch is definitely not needed

Stan added a comment.Feb 26 2021, 3:37 PM

I didn't commit it cause I could not reproduce the bug D1593 looks simple enough for me to commit it. One thing you can do is close this one (abandon) and commandeer the other one so we can finish it.

In D1202#157175, @Stan wrote:

One thing you can do is close this one (abandon) and commandeer the other one so we can finish it.

I will not upload another author's work. In a good way, he himself must change his patch

I didn't commit it cause I could not reproduce the bug D1593 looks simple enough for me to commit it.

Now I have tested build with ToStdString :
with wx 3.1 - successfull build
with wx 3.0.5 - successfull build

I am attaching a patch with ToStdString() for git so that madpilot author can quickly update his work

Stan added a comment.Mar 1 2021, 8:03 PM

Can you check D1593 again?

Stan abandoned this revision.Mar 2 2021, 12:30 AM