The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: jspaces on November 19, 2013, 05:42:55 AM

Title: Latest SVN 6908 fails to compile gui/components/gui_button.o [Fixed]
Post by: jspaces on November 19, 2013, 05:42:55 AM
On ArchLinux 64bit, the latest subversion 6908 fails to build gui_button.o with the following error. It looks like the compiler cannot determine the correct value and points to lines 136 and 119 in display/scr_coord.h.
gui/components/gui_button.cc: In member function 'virtual void button_t::zeichnen(koord)':
gui/components/gui_button.cc:299:148: error: call of overloaded 'scr_rect(const scr_coord, koord&)' is ambiguous
      draw_focus_rect( scr_rect( area.get_pos()+scr_coord(0,(area.get_size().h-gui_theme_t::gui_checkbox_size.y)/2), gui_theme_t::gui_checkbox_size ) );
                                                                                                                                                    ^
gui/components/gui_button.cc:299:148: note: candidates are:
In file included from gui/components/../../display/simgraph.h:21:0,
                 from gui/components/gui_komponente.h:13,
                 from gui/components/gui_button.h:16,
                 from gui/components/gui_button.cc:12:
gui/components/../../display/scr_coord.h:136:2: note: scr_rect::scr_rect(const koord&, const koord&)
  scr_rect( const koord& pt, const koord& size ) { set( pt.x, pt.y, size.x, size.y ); }
  ^
In file included from gui/components/../../display/simgraph.h:21:0,
                 from gui/components/gui_komponente.h:13,
                 from gui/components/gui_button.h:16,
                 from gui/components/gui_button.cc:12:
gui/components/../../display/scr_coord.h:119:2: note: scr_rect::scr_rect(const scr_coord&, const scr_coord&)
  scr_rect( const scr_coord& point1, const scr_coord& point2 ) { set( point1.x, point1.y, point2.x-point1.x, point2.y-point1.y ); }
  ^
common.mk:50: recipe for target 'build/default/gui/components/gui_button.o' failed
make: *** [build/default/gui/components/gui_button.o] Error 1
Title: Re: Latest SVN 6908 fails to compile gui/components/gui_button.o
Post by: Ters on November 19, 2013, 06:10:52 AM
I also just noticed. Someone has committed the sin of having non-explicit conversion constructors from koord to scr_coord, which conspire with methods overloaded to accept either scr_coord or koord in order to break the build.
Title: Re: Latest SVN 6908 fails to compile gui/components/gui_button.o
Post by: prissi on November 19, 2013, 12:09:45 PM
Aparently MSVC was more forgiving than GCC. Or rather MSVC need other explicit conversions, because scr_coord only and conversion of koord is not accepted at all for MSVC.

I submitted a change for the offended line. But I hope a patch from kierongreen to exclusively use scr_coord will cure this.

Title: Re: Latest SVN 6908 fails to compile gui/components/gui_button.o
Post by: isidoro on November 19, 2013, 11:52:11 PM
Since it has to do with this error, I post it here instead of in a new topic:

r6909 has a similar problem:

===> CXX gui/components/gui_scrollbar.cc
gui/components/gui_scrollbar.cc: In member function 'virtual void scrollbar_t::zeichnen(koord)':
gui/components/gui_scrollbar.cc:239:88: error: ambiguous overload for 'operator+' (operand types are 'scr_coord' and 'koord')
   display_img_stretch( gui_theme_t::v_scroll_back_tiles, scr_rect( sliderarea.get_pos()+pos_par, sliderarea.get_size() ) );
                                                                                        ^


In this case, g++ doesn't know how to add an scr_coord and a koord.

Title: Re: Latest SVN 6908 fails to compile gui/components/gui_button.o
Post by: kierongreen on November 20, 2013, 12:15:22 AM
This was the exact reason I went for a complete conversion of all (gui) koords to scr_coords. Once you start converting you really have to just keep going. Hopefully someone will have time to update and commit that patch soon.
Title: Re: Latest SVN 6908 fails to compile gui/components/gui_button.o
Post by: Ters on November 20, 2013, 05:49:21 AM
Quote from: isidoro on November 19, 2013, 11:52:11 PM
In this case, g++ doesn't know how to add an scr_coord and a koord.

In case it isn't clear, g++ knows how to add an scr_coord and koord, it just doesn't know which of the possible ways of doing it the programmer intends. Microsoft's C++ compiler perhaps opts for the simplest solution.
Title: Re: Latest SVN 6908 fails to compile gui/components/gui_button.o
Post by: Dwachs on November 20, 2013, 05:38:56 PM
r6910 compiles again. The fix was as simple as commuting the to arguments to the addition operator  :::)
Title: Re: Latest SVN 6908 fails to compile gui/components/gui_button.o
Post by: jspaces on November 22, 2013, 08:48:08 PM
 :thumbsup: Thanks simutrans developer team for the prompt fix. The scr_coord error(s) no longer appears. Yea!