Hi,
I’m compiling code with AClic inside ROOT CINT.
I have one function like this:
Int_t do_something(const Char_t* name1, const Char_t* name2) {
TCollection::StartGarbageCollection();
cout << "Before: " << endl;
cout << name1 << endl;
cout << name2 << endl;
TFile* f1 = new TFile(name1);
cout << "After: " << endl;
cout << name1 << endl;
cout << name2 << endl;
// do stuff here
return 0;
}
And another function that calls the first one:
Int_t do_it() {
const Char_t* name1 = "f1.root";
const Char_t* name2 = "f2.root";
do_something(name1, name2);
return 0;
}
After compiling, when I run do_it() at the interpreter prompt I get:
Before:
f1.root
f2.root
After:
f1.root
f1.root
I’ve worked around this using TStrings in function do_it(), like this:
Int_t do_it() {
TString n1("f1.root");
TString n2("f2.root");
do_something(n1.Data(), n2.Data());
return 0;
}
And now the output seems ok, but I think there's something seriously wrong with this behaviour... though I don't understand what has gone wrong with the char ponters...
Thank you for your attention, best regards,
Rui