Hi Chris, Doing 'just' #include "Chamber.cxx" and doing .L Chamber.cxx+ #include "Chamber.cxx" are 2 very different operation. The first one is trying to interpret the class Chamber while the second is compiling it. And actually, in the second case, it ignores your #include "Chamber.cxx" In short, you should not use #include "Chamber.cxx" on the ROOT/CINT prompt. The warnings are coming from the fact that Rtypes.h has been included in the interpreted code (probably indirectly). Note that deriving an interpreted class from a compiled class (what happens if you use the first syntax, is not fully supported). Also, you should __not__ use something like: #include "/afs/..../TObject.h" This will make you next upgrade to a newer version of ROOT really annoying. Instead on the compile line you should do: g++ .... `root-config --cflags` .... -----Original Message----- From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Chris Hayward Sent: Monday, July 21, 2003 1:26 PM To: ROOT Talk Mailing List Subject: [ROOT] problems inheriting a class from TObject Hello, I am using ROOT 3.05/06 with gcc 2.96 on lxplus. I have defined a class Chamber that inherits from TObject so that I can use ROOT I/O. I have created a dictionary for the class using rootcint. When I type: #include "Chamber.cxx" in interactive mode of ROOT, I get the following errors: Warning: Re-initialization ignored const kMaxUShort FILE:/afs/cern.ch/sw/root/v3.05.06/rh73_gcc296/root/include/Rtypes.h LINE:97 Warning: Re-initialization ignored const kMaxShort FILE:/afs/cern.ch/sw/root/v3.05.06/rh73_gcc296/root/include/Rtypes.h LINE:98 Warning: Re-initialization ignored const kMaxUInt FILE:/afs/cern.ch/sw/root/v3.05.06/rh73_gcc296/root/include/Rtypes.h LINE:99 Warning: Re-initialization ignored const kMaxInt FILE:/afs/cern.ch/sw/root/v3.05.06/rh73_gcc296/root/include/Rtypes.h LINE:100 Warning: Re-initialization ignored const kBitsPerByte FILE:/afs/cern.ch/sw/root/v3.05.06/rh73_gcc296/root/include/Rtypes.h LINE:103 Warning: Re-initialization ignored const kNPOS FILE:/afs/cern.ch/sw/root/v3.05.06/rh73_gcc296/root/include/Rtypes.h LINE:104 Limitation: Reference member not supported. Please use pointer FILE:/afs/cern.ch/sw/root/v3.05.06/rh73_gcc296/root/include/TGenericClassInf o.h LINE:28 *** Interpreter error recovered *** However, when I type in ROOT: .L Chamber.cxx+ #include "Chamber.cxx" I do not get any errors, and the class works fine. Why is this the case? It would be nice to just work around it, but I fear that this will affect compiled code. Below are my (shortened) header, implementation, and link files for the class Chamber. Thank you in advance for your help. Chris Hayward Chamber.h: #ifndef CHAMBER_INCLUDED //check if the header has already been loaded #define CHAMBER_INCLUDED //if not, set CHAMBER_INCLUDED and proceed #include <iostream.h> #include </afs/cern.ch/sw/root/v3.05.06/rh73_gcc296/root/include/TObject.h> //#include "TObject.h" //TObject is necessary to inherit ROOT I/O #include <string.h> class TDirectory; //needed by ROOT class Chamber:public TObject { //Chamber inherits from TObject //class Chamber { public: Chamber() {}; //default constructor ~Chamber() {}; //variables and member functions defined here ClassDef (Chamber, 4); //a class to store data about MDT chambers }; #endif //CHAMBER_INCLUDED Chamber.cxx: #include "Chamber.h" ClassImp (Chamber); Chamber_LinkDef.h: #ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class Chamber+; #endif //__CINT__
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET