RE: [ROOT] stl members

From: Philippe Canal (pcanal@popgtw.fnal.gov)
Date: Fri Aug 11 2000 - 01:00:32 MEST


Hi,

Currently by default ROOT (and cint) do not know about the class vector<int>
(especially the compiled form).

In order to properly use your class, currently you need to use a linkdef file
like:

x.h <<END
#ifdef __CINT__

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

#pragma link C++ class x;
#pragma link C++ class vector<int>!-;

#endif
END

change you makefile to call:

> 	@rootcint -f ${DICT}.cxx -c ${DHDRS} xlinkdef.h

Philippe.


> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Matevz Tadel
> Sent: Tuesday, August 08, 2000 8:21 AM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] stl members
> 
> 
> Hi,
> 
> I have a stl-container member in a class:
> x.h <<END
> #ifndef _x_h_
> #define _x_h_
> 
> #include <TObject.h>
> #include <vector>
> 
> class x : public TObject{
> public:
>   vector<int>	mV;
> 
>   ClassDef(x,1)
> };
> 
> #endif
> END
> 
> x.cxx <<END
> #include "x.h"
> ClassImp(x)
> END
> 
> doing the rootcint, compile and link routine ...
> excrept from makefile <<END
> all:	dict lib
> 
> %.o: %.cxx
> 	${CXX} ${CPPFLAGS} -c -o $@ ${CXXFLAGS} $<
> 
> ${DICT}.cxx: ${DHDRS}
> 	@echo "Generating dictionary ..."
> 	@rootcint -f ${DICT}.cxx -c ${DHDRS}
> 
> dict:	${DICT}.cxx
> 
> lib:	${DOBJS}
> 	${LD} -shared -o ${OUTLIB} ${DOBJS} ${ROOTLIBS}
> END
> 
> root session:
> root [0] #include <vector>
> root [1] gSystem->Load("xdict.so")
> root [2] x y
> root [3] y.mV.push_back(3)
> Error: Can't call vector<int,__malloc_alloc_template<0> >::push_back(3) in
> current scope FILE:/tmp/fileIZc85C_cint LINE:1
> Possible candidates are...
> filename       line:size busy function type and name  (in
> vector<int,__malloc_alloc_template<0> >)
> *** Interpreter error recovered ***
> 
> shouldn't this work?
> 
> thanks ...
> cheers,
> matevz
> 
> -- 
> ---------------------------------------------------
>  Matevz Tadel,         E-mail: Matevz.Tadel@ijs.si 
>  Department of Experimental High Energy Physics F9 
>  Jozef Stefan Institute,  Jamova 39,  P.o.Box 3000 
>  SI-1001 Ljubljana, Slovenia                       
>  Tel.: +386-61-177-3674      Fax: +386-61-125-7074 
> ---------------------------------------------------
> 
> 
> 



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