Iterator problem in root3.10.02 gcc3.2.3

Hi ,
I had a nice code writing my own classes and vector of classed in a root tree using LinkDef.h and rootcint in root3.10.01 gcc2.96. It works fine.
But when I try to use it in root3.10.02 slc3 gcc3.2.3 although it is compiled, the “iterator” does not work event when I put a line in LinkDef.h like:
#pragma link C++ myclass::iterator
it says "Failed to evaluate operator== "
it happens when I try to do
"
vector::iterator it=myclass.befin();
for(;it!=myclass.end();it++)
"
I think when it reaches == or != these operators have not been defined.

BUT
I did not have this problem in root3.10.01 gc2.96
So I think something is missing in the new versions.
Any help would be great,
Cheers,
Majid

Hi Majid,
this is not valid c++, so I’m surprised gcc 2.96 understood your code.

Here, myclass is a type, but here:

it’s used as a variable name.

It looks like this has nothing to do with root. If you want help here nevertheless, send us code that allows us to understand what’s going on, i.e. what does myclass.end() mean, why is myclass once a variable, once a type etc. Best would be a script that shows this (and no other) problem when compiling it.
Axel.

At some point the default in rootcint was changed from ‘expose everything unless told otherwise’ to ‘expose only what is ask for’.
So your problem is either coming from this change or from a change in the stl library between gcc 2.96 and gcc 3.2.3.

I am not sure what you intend with this pragma. You may have meant:

or

Cheers,
Philippe.

Hi .
Thanks for reply.
I wrote the code in a hurry since I knew the problem does not come from that part! sorry! Now the more clear statement is this:
(in root3.10.01 gcc2.96):

vector mv;//mv has been filled before in another code
for(vector::iterator it=mv.begin();it!=mv.end();it++)

in LinkDef.h I have put:
#pragma link C++ class vector::iterator

this partially works but operator== has been defined!
and in for statement it crashes!
although in root3.10.01 it was working well.
what should I add?
Cheers,
Majid

Hi Majid,
I can reproduce this. I’ll let you know how to fix it once I figured it out myself, i.e. after talking to Philippe Canal :-]
Axel.

Hi,

For gcc 3.2 and higher you need to add

#pragma link C++ function operator==(const vector<myclass>::iterator&,const vector<myclass>::iterator&); #pragma link C++ function operator!=(const vector<myclass>::iterator&,const vector<myclass>::iterator&); #pragma link C++ function operator<=(const vector<myclass>::iterator&,const vector<myclass>::iterator&); #pragma link C++ function operator>=(const vector<myclass>::iterator&,const vector<myclass>::iterator&); #pragma link C++ function operator<(const vector<myclass>::iterator&,const vector<myclass>::iterator&); #pragma link C++ function operator>(const vector<myclass>::iterator&,const vector<myclass>::iterator&); #pragma link C++ function operator-(const vector<myclass>::iterator&,const vector<myclass>::iterator&); #pragma link C++ function operator+(const vector::iterator::difference_type,const vector<myclass>::iterator&);
to your linkdef file.

Cheers,
Philippe.

Thank you Axel and Philppe,
thanks so much…
It is working now.
Cheers,
Majid