RE: [ROOT] push_back problem

From: Philippe Canal (pcanal@fnal.gov)
Date: Wed Nov 19 2003 - 19:12:11 MET


Hi,

I am not sure why you do __both__
   .L FitRing.cxx++
   .L FitRing.cxx
They are 2 alternate way of loading the file.  The former uses the compiler to produce the executable code,
while the later uses the interpreter.

I recommend NOT using 'main' as the name of your function (ACLiC can not expose 'main').

I also recommend using only one '+' as it lets ACLiC decides whether your library really needs to be rebuild or not.

Once I renamed main into FitRing, I can do:
   .L FitRing.cxx+
   FitRing();

Doing both 
   .L FitRing.cxx++
   .L FitRing.cxx
leads to the vector<double> to be not fully initialized. (hence the missing function).
[Actually this would have work anyway if you had generated the cintdlls (because 
you are using std::vector<double> or if you had added

#ifdef __MAKECINT__
#pragma link C++ class vector<double>;
#endif

in you FitRing.cxx file.

Cheers,
Philippe.


-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Reinhardt Chamonal
Sent: Wednesday, November 19, 2003 9:44 AM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] push_back problem


Hi,
I am using root  3.05/05 
I ran into trouble trying to push_back values in a stack.
I do the following in root:

.L FitRing.cxx++
.L FitRing.cxx
main()

The error is:
Error: Can't call vector<double,allocator<double> >::push_back(param1)
in current scope FILE:FitRing.cxx LINE:90
Possible candidates are...
filename       line:size busy function type and name  (in
vector<double,allocator<double> >)
Error: non class,struct,union object $contain used with . or ->
FILE:FitRing.cxx LINE:90


The code is as following:

#include "TH2.h"
#include "TFile.h"
#include "TBenchmark.h"
#include "TAxis.h"
#include "TTree.h"
#include "TF1.h"
#include "TPaveLabel.h"
#include "TCanvas.h"
#include "TSystem.h"

#include <iostream>
#include <vector>

void GetIt(std::vector<double> *contain);

int main(){

  std::vector<double> y;
  GetIt(&y);

}

void GetIt(std::vector<double> *contain)
{
..
double param1=0;
...

 param1=double(total->GetParameter(1));
if(param1!=0) contain->push_back(param1);

...
}


Thanks for the help



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