News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Request for assistance - bizarre error on merge

Started by jamespetts, July 10, 2010, 03:30:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jamespetts

After merging the latest changes to Standard, including the climate settings in the "settings" menu, I get some bizarre Alice in Wonderland like errors that go like this:


1>gui\settings_stats.cc(671): error C2385: ambiguous access of 'add_komponente'
1>          could be the 'add_komponente' in base 'gui_container_t'
1>          or could be the 'add_komponente' in base 'gui_container_t'


I would understand the error if the two things to which the line refers were different, but they're exactly the same, so I am unclear as to where the ambiguity comes from. I have checked to see whether this is an issue that equally affects Standard, but Standard compiles fine. I am a little stuck - does anyone have any suggestions? The broken code is on -devel. Thank you in advance!
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

neroden

I had problems like this before.  It's most likely *linker error*.  Make sure each .cc file is listed exactly once in the Makefile variable SOURCES -- if any file is listed twice, this is the error which results.  (EDIT: of course you're using Microsoft, so find the comparable list of source files.  Make sure nothing is being compiled twice.)

If that's not the problem, then the problem is most likely multiple inheritance: some class is inheriting from gui_container_t *twice* and the two different copies are fighting.  In that case, track back through the ancestry tree and eliminate the duplicate inheritance reference.

If you can't eliminate the duplicate inheritance (for instance, if A inherits from B and C, and B and C each inherit from gui_container_t separately, the 'diamond pattern'), then you have to make sure that gui_container_t is a *virtual base class* -- it's probably become non-virtual for some reason.

neroden

Please note that standard doesn't currently compile on gcc; the climate settings patch introduced a failure-to-compile bug.  I'm currently debugging that and once I fix it I may be able to help debug the merge.

jamespetts

Nathaneal,

thank you very much for your help with this. I have been somewhat too tired to work on this to-day, but think that these warnings might be relevant, given what you wrote above:



1>f:\my documents\development\simutrans\simutrans-experimental-sources\gui\gui_container.h(79): warning C4091: 'virtual ' : ignored on left of 'gui_container_t' when no variable is declared
1>f:\my documents\development\simutrans\simutrans-experimental-sources\gui\settings_stats.h(209): warning C4584: 'settings_climates_stats_t' : base-class 'gui_container_t' is already a base-class of 'settings_stats_t'
1>          f:\my documents\development\simutrans\simutrans-experimental-sources\gui\gui_container.h(24) : see declaration of 'gui_container_t'
1>          f:\my documents\development\simutrans\simutrans-experimental-sources\gui\settings_stats.h(133) : see declaration of 'settings_stats_t'
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

neroden

Quote from: jamespetts on July 10, 2010, 10:49:01 PM
Nathaneal,

thank you very much for your help with this. I have been somewhat too tired to work on this to-day, but think that these warnings might be relevant, given what you wrote above:



1>f:\my documents\development\simutrans\simutrans-experimental-sources\gui\gui_container.h(79): warning C4091: 'virtual ' : ignored on left of 'gui_container_t' when no variable is declared
1>f:\my documents\development\simutrans\simutrans-experimental-sources\gui\settings_stats.h(209): warning C4584: 'settings_climates_stats_t' : base-class 'gui_container_t' is already a base-class of 'settings_stats_t'
1>          f:\my documents\development\simutrans\simutrans-experimental-sources\gui\gui_container.h(24) : see declaration of 'gui_container_t'
1>          f:\my documents\development\simutrans\simutrans-experimental-sources\gui\settings_stats.h(133) : see declaration of 'settings_stats_t'


Bingo.

The reason standard is working is that gui_container_t is *not* a public base class of settings_stats_t in standard.

Bernd caused settings_stats_t to inherit from gui_container_t in experimental.

It's all related to this commit from Bernd:
http://github.com/neroden/simutrans/commit/13c4b9ffaec79f50f63847ce4a0752de4c758957

You have to apply the same change to the new class settings_climate_stats_t which Bernd already applied to all the previously existing similar classes.  Replace this line in settings_stats.h:
class settings_climates_stats_t : protected settings_stats_t, public gui_container_t, public action_listener_t
with this:
class settings_climates_stats_t : public settings_stats_t, public action_listener_t

I'm betting that will do the trick.  But I haven't tested it yet. If you have any further problems don't hesitate to ask.  :-)

jamespetts

Ahh, thank you very much! That does help. Most kind.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.