Double-counting in rootcint generating templates

From: George Heintzelman (gah@bnl.gov)
Date: Wed Jan 26 2000 - 19:30:30 MET


Hi Rooters,

A minor (I think) but annoying bug in rootcint for templates:
If the LinkDef file contains a line like:

#pragma link C++ class Template<Int_t>

where Int_t really means 'any typedef'd class', rootcint will get 
confused and generate the Streamer/Showmembers functions twice. This is 
because the full translation of the template name is not being done 
when rootcint is checking to see if the class has already been 
processed.

The resulting effect is that the dictionary generated bombs with a 
redefined function error. You can fix this by instead doing the 
'typedef by hand' in the LinkDef file.

Example code:

test_tempclass.h:
----------------------------------------
#ifndef _test_tempclass_h_
#define _test_tempclass_h_

#include "Rtypes.h"

template <class T>
class Temp {
  T fMemb;

ClassDefT(Temp<T>,0)

};

ClassDefT2(Temp,T)

#endif
----------------------------------------

LinkDef.h:
----------------------------------------
#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class Temp<Int_t>-;
// the '-' flag is used so we can see messages about the streamer; I 
know
// it's not defined
// #pragma link C++ class Temp<int>-; // works fine.
#endif
----------------------------------------

Test run:
----------------------------------------
rcas4008 % rootcint TestCint.cxx -c test_tempclass.h LinkDef.h
Note: operator new() masked 1c
Note: operator delete() masked 1c
class Temp<int> in test_tempclass.h line 7 original base of virtual func
Class Temp<int>: Do not generate Streamer() [*** custom streamer ***]
Class Temp<int>: Do not generate Streamer() [*** custom streamer ***]

   Note the repeated messages about Temp<int>.

rcas4008 % g++ -I$ROOTSYS/include -c TestCint.cxx
TestCint.cxx:43: duplicate specialization of Temp<int>::ShowMembers<int>
(TMemberInspector &, char *)
TestCint.cxx:43: redefinition of `void Temp<int>::ShowMembers<int>
(class TMemberInspector &, char *)'
TestCint.cxx:22: `void Temp<int>::ShowMembers<int>(class 
TMemberInspector &, char *)' previously defined here
-----------------------------------------

George Heintzelman
gah@bnl.gov



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET