RE:virtual base classes in CINT

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Mon Feb 15 1999 - 15:31:12 MET


Christian,

ROOT does not allow multiple inheritance as far as I understand.

The first case is a CINT problem. Cint tries to map derived class object to
base class in the dictionary but it is ambiguous. 

Second case is a ROOT  problem. TObject does not allow multiple inheritance.
If you do not use any of the ROOT classes, this case will work.

Please go around without using multiple inheritance in ROOT/CINT.

Masaharu Goto

----------------------------------------------------------------------
hi masa.

i have a question about how to do a certain multiple inheritance.
my inheritance tree looks like this:
-------------------------------------------------------------------------


                TGraph
                  /\
                 /  \ virtual
                /    \
     TGraphErrors    TLookUp
                \    /
                 \  /
                  \/
             TLookUpErrors


-------------------------------------------------------------------------
TGraph and TGraphErrors are ROOT classes.
TLookUp and TLookUpErrors are my own.

when i compile the rootcint dictionary, i get 26 errors like these:
-------------------------------------------------------------------------


error
        "TLookUp.dict.cxx", line 299: error(3367):
        base class "TGraph" is ambiguous

        TGraph *G__Lbase=G__Lderived;
                         ^        
error
        "TLookUp.dict.cxx", line 305: error(3367):
        base class "TNamed" is ambiguous

        TNamed *G__Lbase=G__Lderived;
                         ^        
error
        "TLookUp.dict.cxx", line 311: error(3367):
        base class "TObject" is ambiguous

        TObject *G__Lbase=G__Lderived;
                          ^        
error
        "TLookUp.dict.cxx", line 317: error(3367):
        base class "TAttLine" is ambiguous

        TAttLine *G__Lbase=G__Lderived;
                           ^        


-------------------------------------------------------------------------
if i edit the ROOT header file TGraphErrors.h to make TGraph a virtual
base class of TGraphErrors, then the "diamond of death" looks like this:
-------------------------------------------------------------------------


                TGraph
                  /\
         virtual /  \ virtual
                /    \
     TGraphErrors    TLookUp
                \    /
                 \  /
                  \/
             TLookUpErrors


-------------------------------------------------------------------------
and i get only 2 errors when i compile the dictionary:
-------------------------------------------------------------------------

warning
        "TLookUp.dict.cxx", line 377: warning(3666):
        variable "G__Lderived" was set but never used

        TLookUp *G__Lderived;
                 ^        
error
        "TLookUp.dict.cxx", line 734: error(3369):
        derived class "TLookUp" has class "TObject" as a virtual base
        class

        obj = (TLookUp *) buf.ReadObject(TLookUp::Class());
                              ^        
error
        "TLookUp.dict.cxx", line 772: error(3369):
        derived class "TLookUpErrors" has class "TObject" as a virtual
        base class

        obj = (TLookUpErrors *) buf.ReadObject(TLookUpErrors::Class());
                                    ^        
        2 errors detected in the compilation of "TLookUp.dict.cxx".


-------------------------------------------------------------------------
i don't understand where these errors come from,
but i can get rid of them by commenting out the corresponding lines
of code from the dictionary file TLookUp.dict.cxx

then the shared object will compile, but when i try to load it into root
there is an unresolved symbol:
-------------------------------------------------------------------------

root> gSystem->Load("TLookUp.so")
dlopen error:   696:/tmp/r/bin/root.exe: rld: Fatal Error: unresolvable
symbol in /home/cdfsg5/d6/bdata/lacunza/root/lib/TLookUp.so:
__vtbl__6TGraph__12TGraphErrors
Load Error: Dynamic link library
/home/cdfsg5/d6/bdata/lacunza/root/lib/TLookUp.so can not load
(int)(-1)
*** Interpreter error recovered ***
root> 


-------------------------------------------------------------------------
can you tell me what's going on here?
i've attached the header file and the LinkDef file in case you want to
look at them.

-- christian.


---2147286486-1548151140-918821536=:582
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="LinkDef.h"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:29 MET