[omniORB] Ambiguous inheritance error

Gary D. Duzan gdd0@gte.com
Tue, 23 Feb 1999 13:28:02 -0500


   Here's an idea. What if you added the following bits:

================================================================================
class C_i : public virtual A_i,
	    public virtual B_i,
	    public virtual Test::_sk_C {
  ...

#ifdef __OMNIORB2__
public:
  CORBA::Boolean dispatch(GIOP_S &_0RL_s,const char *_0RL_op,
			  CORBA::Boolean _0RL_response_expected) {
    return(TEST::_sk_C::dispatch(_0RL_s,_0RL_op,_0RL_response_expected));
  }

protected:
  void *_widenFromTheMostDerivedIntf(const char *repoId,
				     CORBA::Boolean is_cxx_type_id) {
    return(TEST::_sk_C::_widenFromTheMostDerivedIntf(repoId,is_cxx_type_id));
  }
#endif // def(__OMNIORB2__)

  ...
};
================================================================================

Or something like that. Explicitly remove the ambiguity and do what may
even be the right thing. This is a gross hack, and I have no clue if
this will actually work, but it might save a lot of work if it does.

					Gary Duzan
					GTE Laboratories


p.s. C++ is an evil, evil thing. Too bad it is so useful.


In Message <86256721.005E3550.00@ln1.gd-is.com> ,
   Rebecca.A.Sanford@notesmta.gd-is.com wrote:

=>
=>
=>Hi,
=>
=>Sorry for bothering you again, but I'm a little confused by your
=>suggestion.  It sounds like you are suggesting an extra layer in
=>which the members of C_i would call the appropriate A_i and B_i member
=>functions.  That would add a lot of call overhead and I'm unclear how
=>constructors and destructors for A_i and B_i would be handled.
=>
=>I have used similar IDL and header files with IONA's Orbix without a
=>problem.  I was attempting to port the code to omniORB to test for
=>interoperability between ORBs.  My actual code contains hundreds of
=>functions so perhaps you can understand my lack of eagerness to add
=>this extra layer.
=>
=>If I'm way off-base, please let me know at your earliest convenience.
=>Thanks again for your time.
=>
=>Becki Sanford
=>General Dynamics Information Systems
=>Bloomington, MN
=>email: r.sanford@gd-is.com
=>
=>
=>
=>
=>
=>
=>David Riddoch <djr@uk.research.att.com> on 02/23/99 03:54:00
=>
=>To:   Rebecca A Sanford/GDIS/GDYN@GDIS
=>cc:   omniorb@uk.research.att.com
=>Subject:  Re: [omniORB] Ambiguous inheritance error
=>
=>
=>
=>
=>
=>Hi Rebecca,
=>
=>
=>The reason you are having problems is that you are using C++ inheritance
=>to inherit both interface and implementation. The _sk_?? classes provide
=>part of the internal implementation of omniORB2, which is then provided
=>more than once if you inherit from multiple _sk_?? classes as you have
=>done.
=>
=>The correct way to inherit the interface is as follows:
=>
=> // File: test_i.h
=> #include "test.hh"
=>
=> class A_i : public Test::_sk_A {
=>   ... as you did ...
=> };
=>
=> ... B similarly ...
=>
=> class C_i : public Test::_sk_C {
=>   void A_foo_1();
=>   void A_foo_2();
=>   void B_foo_1();
=>   void B_foo_2();
=>   void C_foo_1();
=>   void C_foo_2();
=> };
=>
=>The problem with this though is that we aren't inheriting the
=>implementation of A_foo_1() etc. You could achieve this by having separate
=>classes which provide the implementation for A and B, and have C_i inherit
=>from them. The implementations of A_foo_1() and friends would then just
=>delagate to that class.
=>
=>
=>Hope this helps,
=>David
=>
=>
=>PS. Its a good idea to send this sort of question to the mailing list, as
=>it would then be seen by a wider audience, and the answer may help others.
=>
=>
=>
=>On Mon, 22 Feb 1999 Rebecca.A.Sanford@notesmta.gd-is.com wrote:
=>
=>> Perhaps you can help me out with a problem I'm having with multiple
=>> inheritance with the omniORB (version 2.70). I'm compiling with MS
=>> Visual C++ 5.0 on NT 4.0.  My IDL is structured as follows:
=>>
=>>
=>>      // IDL
=>>      module Test {
=>>
=>>         interface A {
=>>            void A_foo_1 ();
=>>            void A_foo_2 ();
=>>         };
=>>
=>>         interface B {
=>>            void B_foo_1 ();
=>>            void B_foo_2 ();
=>>         };
=>>
=>>         interface C : A, B {
=>>            void C_foo_1 ();
=>>            void C_foo_2 ();
=>>         };
=>>      };
=>>
=>>
=>> I then created the following header file to define my classes:
=>>
=>>
=>>      // File: test_i.h
=>>      #include "test.hh"
=>>
=>>      class A_i : public virtual Test::_sk_A {
=>>      public:
=>>         void A_foo_1 ();
=>>         void A_foo_2 ();
=>>      };
=>>
=>>      class B_i : public virtual Test::_sk_B {
=>>      public:
=>>         void B_foo_1 ();
=>>         void B_foo_2 ();
=>>      };
=>>
=>>      class C_i : public virtual A_i,
=>>                  public virtual B_i,
=>>                  public virtual Test::_sk_C {
=>>      public:
=>>         void C_foo_1 ();
=>>         void C_foo_2 ();
=>>      };
=>>
=>>
=>> When I attempt to define an object of type "C_i", I get a compiler
=>> error stating that 'C_i' has ambiguous inheritances of _sk_C::dispatch
=>> and _sk_C::_widenFromTheMostDerivedIntf().
=>>
=>> Since the IDL compiler inserts those two functions, does this mean that
=>> I cannot use multiple inheritances?  Is there a workaround to this
=>> problem?  Any information you can toss my way will be greatly appreciated.
=>> Thank you in advance for your time and consideration.