I have found a few other topics that were similar to this but still do not know how to fix it. Could someone please explain why this is happening and how to fix it?
root [0] .L tdiEntry.C+
root [1] #include <vector>
root [2] gInterpreter->GenerateDictioanry("vector< tdiEntry>","tdiEntry.C;vector");
Error: Can't call TCint::GenerateDictioanry("vector< tdiEntry>","tdiEntry.C;vector") in current scope (tmpfile):1:
Possible candidates are...
*** Interpreter error recovered ***
When I was trying to create that vector withing the application I am working on right now three other files were created
AutoDict_vector_tdiEntry_.cxx
#include "vector"
#include "tdiEntry.C"
#ifdef __CINT__
#pragma link C++ nestedclasses;
#pragma link C++ nestedtypedefs;
#pragma link C++ class vector<tdiEntry>+;
#pragma link C++ class vector<tdiEntry>::*;
#ifdef G__VECTOR_HAS_CLASS_ITERATOR
#pragma link C++ operators vector<tdiEntry>::iterator;
#pragma link C++ operators vector<tdiEntry>::const_iterator;
#pragma link C++ operators vector<tdiEntry>::reverse_iterator;
#endif
#endif
AutoDict_vector_tdiEntry__cxx.d
# DO NOT DELETE
AutoDict_vector_tdiEntry__cxx.so: tdiEntry.C
AutoDict_vector_tdiEntry__cxx.so: /home/radu/Desktop/sources/root-trunk/include/cintdictversion.h /home/radu/Desktop/sources/root-trunk/include/RVersion.h
AutoDict_vector_tdiEntry__cxx__ROOTBUILDVERSION= 5.29/03
The real problem is thattdiEntry *item = new tdiEntry("trial item");
vector<tdiEntry> myVector;
myVector.push_back(item);is illegal C++ as the vector expects object and ‘item’ is a pointer. You need either:tdiEntry *item = new tdiEntry("trial item");
vector<tdiEntry*> myVector;
myVector.push_back(item);ortdiEntry item("trial item");
vector<tdiEntry> myVector;
myVector.push_back(item);ortdiEntry *item = new tdiEntry("trial item");
vector<tdiEntry> myVector;
myVector.push_back(*item);
root [2] gInterpreter->GenerateDictioanry("vector< tdiEntry>","tdiEntry.C;vector");
Error: Can't call TCint::GenerateDictioanry("vector< tdiEntry>","tdiEntry.C;vector") in current scope is a typo, the actually function name is GenerateDictionary. (But you probably do not really need it)
I have similar problem, but cannot solve it with the above.
I do
.L code.cpp++
run("filename")
the code is (in brief)
...
vector<TH1D*> histograms;
...
histograms.push_back(new TH1D(...));
fill...
draw...
ok up to here.
Then in the interactive/interpreter I try to access the histograms, but:
although it sees the vector:
>histograms
(class vector<TH1D*>)140681640470768
it does not allow access (or I do not know how to).
>histograms.at(0)
Error: Can't call vector<TH2D*,allocator<TH2D*> >::at(0) in current scope (tmpfile):1:
Possible candidates are...
(in vector<TH1D*,allocator<TH1D*> >)
*** Interpreter error recovered ***