News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Latest SVN 6908 fails to compile gui/components/gui_button.o [Fixed]

Started by jspaces, November 19, 2013, 05:42:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jspaces

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

Ters

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.

prissi

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.


isidoro

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.


kierongreen

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.

Ters

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.

Dwachs

r6910 compiles again. The fix was as simple as commuting the to arguments to the addition operator  :::)
Parsley, sage, rosemary, and maggikraut.

jspaces

 :thumbsup: Thanks simutrans developer team for the prompt fix. The scr_coord error(s) no longer appears. Yea!