Page MenuHomeWildfire Games

Patches required to work with latest clang on FreeBSD
Needs ReviewPublic

Authored by madpilot on Jul 5 2018, 4:48 PM.

Details

Reviewers
Itms
Trac Tickets
#5255
Summary

FreeBSD 12 includes clang version 6.0.1 (imported a few days ago, I tested with 6.0.0).

This compiler is really picky about standards and a few lines required changing:

in AtlasObjectImpl.ccp clang was erroring out due to the calls to add and set being considered ambiguous.

I took a brutal approach and duplicated the code inside the functions calling them directly. This can be made better, but I'm not a C++ expert, so I did not spend too much time thinking about it.

In MapDialog.cpp and ScenarioEditor.cpp the calls to wxString::wc_str() return wchar_t*, but the constructor they are passed into expects std::wstring so I changed the call to wxString::ToStdWstring(), returning the expected type.

Test Plan

The patches compile and work fine in FreeBSD, at least for a short playtest.

If a specific test is requested I can perform that.

Patches already committed to the FreeBSD ports tree.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
/ps/trunk
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 6276
Build 10416: Vulcan BuildJenkins
Build 10415: arc lint + arc unit

Event Timeline

madpilot created this revision.Jul 5 2018, 4:48 PM
Owners added a subscriber: Restricted Owners Package.Jul 5 2018, 4:49 PM
Vulcan added a subscriber: Vulcan.Jul 5 2018, 4:53 PM

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

Link to build: https://jenkins.wildfiregames.com/job/differential/673/display/redirect

Could you attach your errors?

Here is the error for the add call (the one for set is the same):

c++ -O2 -pipe -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing  -DLIBICONV_PLUG -DU_USING_ICU_NAMESPACE=1 -DLIBICONV_PLUG -MMD -MP -DNDEBUG -DCONFIG_FINAL=1 -DLIB_STATIC_LINK -DINSTALLED_BINDIR=/usr/local/bin -DINSTALLED_DATADIR=/usr/local/share/0ad -DINSTALLED_LIBDIR=/usr/local/lib/0ad -I../../../source/tools/atlas/AtlasObject -I../../../source/third_party/jsonspirit -isystem /usr/local/include/libxml2 -isystem /usr/local/lib/wx/include/gtk2-unicode-3.0 -isystem /usr/local/include/wx-3.0 -isystem /usr/X11R6/include/X11 -isystem /usr/X11R6/include -isystem /usr/local/include/X11 -isystem /usr/local/include -isystem /usr/include/X11 -O3 -g -Wall -Wextra -Wno-switch -Wno-reorder -Wno-invalid-offsetof -Wextra -Wno-missing-field-initializers -Wunused-parameter -Wredundant-decls -Wnon-virtual-dtor -Wundef -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstrict-aliasing -fno-omit-frame-pointer -fpch-preprocess -std=c++0x -fvisibility=hidden -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -D_THREAD_SAFE -rdynamic -fPIC -Wno-unused-local-typedefs  -o "obj/AtlasObject_Release/AtlasObjectImpl.o" -MF "obj/AtlasObject_Release/AtlasObjectImpl.d" -c "../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp"
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:167:2: error: call to member function 'add' is ambiguous
        add(key, value.wc_str());
        ^~~
../../../source/tools/atlas/AtlasObject/AtlasObject.h:160:7: note: candidate function
        void add(const char* key, const wchar_t* value);
             ^
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:165:13: note: candidate function
void AtObj::add(const char* key, const wxString& value)
            ^
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:157:13: note: candidate function not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'AtObj &' for 2nd argument
void AtObj::add(const char* key, AtObj& data)
            ^
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:190:2: error: call to member function 'set' is ambiguous
        set(key, value.wc_str());
        ^~~
../../../source/tools/atlas/AtlasObject/AtlasObject.h:163:7: note: candidate function
        void set(const char* key, const wchar_t* value);
             ^
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:188:13: note: candidate function
void AtObj::set(const char* key, const wxString& value)
            ^
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:180:13: note: candidate function not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'AtObj &' for 2nd argument
void AtObj::set(const char* key, AtObj& data)
            ^
2 errors generated.

Here is the one for the wxString::wc_str() :

c++ -O2 -pipe -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing  -DLIBICONV_PLUG -DU_USING_ICU_NAMESPACE=1 -DLIBICONV_PLUG -MMD -MP -DNDEBUG -DCONFIG_FINAL=1 -DLIB_STATIC_LINK -DINSTALLED_BINDIR=/usr/local/bin -DINSTALLED_DATADIR=/usr/local/share/0ad -DINSTALLED_LIBDIR=/usr/local/lib/0ad -DUSING_PCH -I../../../source/tools/atlas/AtlasUI -I../../../source/tools/atlas -I../../../source/tools/atlas/AtlasUI/CustomControls -I../../../source/tools/atlas/AtlasUI/Misc -isystem /usr/local/include/libxml2 -isystem /usr/local/include/SDL2 -isystem /usr/local/lib/wx/include/gtk2-unicode-3.0 -isystem /usr/local/include/wx-3.0 -isystem /usr/X11R6/include/X11 -isystem /usr/X11R6/include -isystem /usr/local/include/X11 -isystem /usr/local/include -isystem /usr/include/X11 -O3 -fPIC -g -Wall -Wextra -Wno-switch -Wno-reorder -Wno-invalid-offsetof -Wextra -Wno-missing-field-initializers -Wunused-parameter -Wredundant-decls -Wnon-virtual-dtor -Wundef -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstrict-aliasing -fno-omit-frame-pointer -fpch-preprocess -std=c++0x -fvisibility=hidden -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -D_THREAD_SAFE -rdynamic -fPIC -Wno-unused-local-typedefs -include obj/AtlasUI_Release/precompiled.h -o "obj/AtlasUI_Release/MapDialog.o" -MF "obj/AtlasUI_Release/MapDialog.d" -c "../../../source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp"
../../../source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp:169:32: error: no matching constructor for initialization of 'AtlasMessage::qVFSFileExists'
                AtlasMessage::qVFSFileExists qry(filePath.wc_str());
                                             ^   ~~~~~~~~~~~~~~~~~
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'const AtlasMessage::qVFSFileExists' for 1st argument
QUERY(VFSFileExists,
^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../../../source/tools/atlas/GameInterface/MessagesSetup.h:176:2: note: expanded from macro 'QUERY_WITH_INPUTS'
        QUERYSTRUCT(name) \
        ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:81:9: note: expanded from macro 'QUERYSTRUCT'
        struct q##t : public QueryMessage { \
               ^
<scratch space>:164:1: note: expanded from here
qVFSFileExists
^
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'std::wstring' (aka 'basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >') for 1st argument
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
/usr/local/include/boost/preprocessor/control/iif.hpp:31:31: note: expanded from macro 'BOOST_PP_IIF_0'
# define BOOST_PP_IIF_0(t, f) f
                              ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:177:3: note: expanded from macro 'QUERY_WITH_INPUTS'
                q##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, in_vals) ) \
                ^
<scratch space>:167:1: note: expanded from here
qVFSFileExists
^
../../../source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp:173:35: error: no matching constructor for initialization of 'AtlasMessage::qVFSFileRealPath'
                        AtlasMessage::qVFSFileRealPath qry(filePath.wc_str());
                                                       ^   ~~~~~~~~~~~~~~~~~
../../../source/tools/atlas/GameInterface/Messages.h:213:1: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'const AtlasMessage::qVFSFileRealPath' for 1st argument
QUERY(VFSFileRealPath,
^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../../../source/tools/atlas/GameInterface/MessagesSetup.h:176:2: note: expanded from macro 'QUERY_WITH_INPUTS'
        QUERYSTRUCT(name) \
        ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:81:9: note: expanded from macro 'QUERYSTRUCT'
        struct q##t : public QueryMessage { \
               ^
<scratch space>:81:1: note: expanded from here
qVFSFileRealPath
^
../../../source/tools/atlas/GameInterface/Messages.h:213:1: note: candidate constructor not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'std::wstring' (aka 'basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >') for 1st argument
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
/usr/local/include/boost/preprocessor/control/iif.hpp:31:31: note: expanded from macro 'BOOST_PP_IIF_0'
# define BOOST_PP_IIF_0(t, f) f
                              ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:177:3: note: expanded from macro 'QUERY_WITH_INPUTS'
                q##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, in_vals) ) \
                ^
<scratch space>:84:1: note: expanded from here
qVFSFileRealPath
^
../../../source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp:224:31: error: no matching constructor for initialization of 'AtlasMessage::qVFSFileExists'
        AtlasMessage::qVFSFileExists qry(filePath.wc_str());
                                     ^   ~~~~~~~~~~~~~~~~~
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'const AtlasMessage::qVFSFileExists' for 1st argument
QUERY(VFSFileExists,
^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../../../source/tools/atlas/GameInterface/MessagesSetup.h:176:2: note: expanded from macro 'QUERY_WITH_INPUTS'
        QUERYSTRUCT(name) \
        ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:81:9: note: expanded from macro 'QUERYSTRUCT'
        struct q##t : public QueryMessage { \
               ^
<scratch space>:164:1: note: expanded from here
qVFSFileExists
^
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'std::wstring' (aka 'basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >') for 1st argument
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
/usr/local/include/boost/preprocessor/control/iif.hpp:31:31: note: expanded from macro 'BOOST_PP_IIF_0'
# define BOOST_PP_IIF_0(t, f) f
                              ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:177:3: note: expanded from macro 'QUERY_WITH_INPUTS'
                q##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, in_vals) ) \
                ^
<scratch space>:167:1: note: expanded from here
qVFSFileExists
^
../../../source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp:239:31: error: no matching constructor for initialization of 'AtlasMessage::qVFSFileExists'
        AtlasMessage::qVFSFileExists qry(filePath.wc_str());
                                     ^   ~~~~~~~~~~~~~~~~~
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'const AtlasMessage::qVFSFileExists' for 1st argument
QUERY(VFSFileExists,
^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../../../source/tools/atlas/GameInterface/MessagesSetup.h:176:2: note: expanded from macro 'QUERY_WITH_INPUTS'
        QUERYSTRUCT(name) \
        ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:81:9: note: expanded from macro 'QUERYSTRUCT'
        struct q##t : public QueryMessage { \
               ^
<scratch space>:164:1: note: expanded from here
qVFSFileExists
^
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'std::wstring' (aka 'basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >') for 1st argument
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
/usr/local/include/boost/preprocessor/control/iif.hpp:31:31: note: expanded from macro 'BOOST_PP_IIF_0'
# define BOOST_PP_IIF_0(t, f) f
                              ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:177:3: note: expanded from macro 'QUERY_WITH_INPUTS'
                q##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, in_vals) ) \
                ^
<scratch space>:167:1: note: expanded from here
qVFSFileExists
^