RE: [ROOT] Is it possible to use ClassDef and ClassImp with a template class?

From: Philippe Canal (pcanal@fnal.gov)
Date: Thu May 22 2003 - 13:01:07 MEST


Hi Micha,

You are currently generating the dictionary with a command line looking
like:

	rootcint testDict.C -c test.C

When a linkdef file is not specified the default behavior of rootcint is to
assume that there is a concrete class with the same as the filename without
the extension.  This is not your case and you have to introduce a linkdef
file.  In the case of templates rootcint can only generate dictionary for
specific instance of the template.  So you would need to introduce a linkdef
file looking like:

	// Start of testLinkdef.h
	#ifdef __CINT__
	#pragma link C++ class test<double>+;
	#endif

and use rootcint like:

	rootcint testDict.C -c test.C testLinkdef.h

Cheers,
Philippe

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Micha D. Niskin
Sent: Wednesday, May 21, 2003 5:26 PM
To: roottalk@cern.ch
Subject: Re: [ROOT] Is it possible to use ClassDef and ClassImp with a
template class?


Thanks for your reply. The classname should have been 'test' not 'temp' in
my
example, by the way. That was a typo. I changed the 'ClassDef(test<T>,1)' to
'ClassDef(test,1)' and 'ClassImp(test<T>)' to 'templateClassImp(test)', as
you suggested. However now I get the following errors:

[mdn@hermit root_template_test_class]$ make
g++ -O -Wall -fPIC -D_REENTRANT -I/home/mdn/root/include   -c -o test.o
test.C
Generating dictionary...
Error: link requested for unknown class test FILE:G__auto27458LinkDef.h
LINE:7
Warning: Error occured during reading source files
Warning: Error occured during dictionary source generation
!!!Removing testDict.C testDict.h !!!
Error: rootcint: error loading headers...
make: *** [testDict.C] Error 1

I have attached the source and make files below. Thanks again!



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET