[ROOT] Problem with rootcint and derived template classes

From: Me (gora@coyote.ucr.edu)
Date: Wed Apr 19 2000 - 12:08:15 MEST


Hello,
  I have been having some strange mail problems in sending messages to ROOT
talk and to the ROOT maintainers. What is the canonical address to send
messages to the mailing list? This one is being sent to an address found by
searching for "roottalk" on the Web page. Shouldn't the Majordomo welcome
message that I carefully preserved contain this information?

  I have run into a problem with rootcint in deriving template classes from a
base class. Attached to these messages are the following files containing a
trivial example that reproduces the problem:
  classA.cxx, classA.h   Base template class
  classALinkDef.h        rootcint LinkDef file for classA
  classB.cxx, classB.h   Template class derived from classA
  classBLinkDef.h        rootcint LinkDef file for classB
  Makefile               simple Makefile for all programs
You can try compiling these simply by typing 'make' at a Linux command prompt.
I am using ROOT v2.23 on a Linux box (Suse 6.2, kernel 2.2.10) with g++ 2.95.1.
Here are the g++ warnings and errors that I get:
classADict.cxx:22: warning: explicit specialization not preceded by `template <>'
classADict.cxx:34: warning: explicit specialization not preceded by `template <>'
classADict.cxx:44: warning: explicit specialization not preceded by `template <>'
...

classBDict.cxx:31: warning: explicit specialization not preceded by `template <>'
classBDict.cxx:45: warning: explicit specialization not preceded by `template <>'
classBDict.cxx:56: warning: explicit specialization not preceded by `template <>'
classBDict.cxx:66: warning: explicit specialization not preceded by `template <>'
classBDict.cxx:66: specialization of TClassA<int>::Streamer(TBuffer &) after instantiation
classBDict.cxx:66: explicit specialization of TClassA<int>::Streamer(TBuffer &) after first use
classBDict.cxx:78: warning: explicit specialization not preceded by `template <>'
classBDict.cxx:78: specialization of TClassA<int>::ShowMembers(TMemberInspector &, char *) after instantiation
classBDict.cxx:78: explicit specialization of TClassA<int>::ShowMembers(TMemberInspector &, char *) after first use
classBDict.cxx:88: warning: explicit specialization not preceded by `template <>'
make: *** [all] Error 1

The warnings can be fixed by adding "template <>" before the appropriate
functions. The error results from TClassA<int>::Streamer() being used before
it is defined, and can be fixed by moving the TClassB<int>::Streamer()
definition to after the TClassA<int>::Streamer() definition. It would be nice
if rootcint would do these automatically. Thanks in advance.

Regards,
Gora



#include <Rtypes.h>
template <class T>
class TClassA {
public:
  TClassA() {};
  virtual ~TClassA() {};
  ClassDefT(TClassA, 1)
};
ClassDefT2(TClassA, T)


#include "classA.h"
ClassImpT(TClassA, T)


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

#pragma link C++ class TClassA<int>;
#endif


#include <Rtypes.h>
#include "classA.h"
template <class T>
class TClassB : public TClassA<T> {
public:
  TClassB() {};
  virtual ~TClassB() {};
  ClassDefT(TClassB, 1)
};
ClassDefT2(TClassB, T)


#include "classB.h"
ClassImpT(TClassB, T)


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

#pragma link C++ class TClassB<int>;
#endif


all:
#	g++ -O2     -ansi -pedantic -Wall -I$(ROOTSYS)/include -c -o classA.o classA.cxx
#	$(ROOTSYS)/bin/rootcint -f classADict.cxx -c -p classA.h classALinkDef.h
#	g++ -O2     -ansi -pedantic -Wall  -I$(ROOTSYS)/include -c -o classADict.o classADict.cxx
#	g++ -O2     -ansi -pedantic -Wall  -I$(ROOTSYS)/include -c -o classB.o classB.cxx
#	$(ROOTSYS)/bin/rootcint -f classBDict.cxx -c -p  -I$(ROOTSYS)/include classB.h classBLinkDef.h
#	g++ -O2     -ansi -pedantic -Wall  -I$(ROOTSYS)/include -c -o classBDict.o classBDict.cxx
	g++ -O2     -ansi -pedantic -Wall -I/home/gora/programs/include -I$(ROOTSYS)/include -c -o classC.o classC.cxx
	$(ROOTSYS)/bin/rootcint -f classCDict.cxx -c -I/home/gora/programs/include -p classC.h classCLinkDef.h
	g++ -O2     -ansi -pedantic -Wall  -I/home/gora/programs/include -I$(ROOTSYS)/include -c -o classCDict.o classCDict.cxx



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