For some reason, when I define a variable as "uint" instead of "unsigned int" in my program, it errors. This seems strange, because uint is typedef'd as:
typedef unsigned int uint;
...so I would think that I could use the two interchangeably. To be more exact, I am assigning the result of a function which returns "unsigned int" into a uint variable, then using that uint in a vector resize call... at which point it errors. Ie, my code looks something like this:
unsigned int getUInt()
{
return 3;
}
int main(void) {
vector<vector<float> > vectVect(100000);
for(uint i = 0; i < vectVect.size(); ++i)
{
vector<float>& myVect = vectVect[i];
uint myUnsignedInt = getUInt();
myVect.resize(myUnsignedInt);
}
cout << "finished" << endl;
}
...and the line it errors at is the myVect.resize line.
Obviously, I already have a solution, but I'd like to understand WHY this is happening, as I'm pretty baffled. Anyone have any ideas?
PS - In case anyone thinks it may matter, I'm using gcc v4.1.2 on fedora 15... and the include file which defines uint is /usr/include/sys/types.h.
My guess is that there is another uint in the system. Try renaming yours to something unusual or even better wrap it in a namespace.
namespace MY {
typedef unsigned int uint;
}
for (MY::uint i = 0; ....