Re: Change in template class handling?
Re: Change in template class handling?
- Subject: Re: Change in template class handling?
- From: Chris Espinosa <email@hidden>
- Date: Tue, 25 Apr 2006 15:48:39 -0700
On Apr 25, 2006, at 2:52 PM, Mark Wagner wrote:
A .cpp file containing the following code compiles on CodeWarrior 9
and Xcode 1.5/GCC 3.3, but not on Xcode 2.2/GCC 4. It shouldn't
compile -- class TArrayOfObj has no member named "len" and there is no
global variable called "len", and pOiArray is a struct with no member
functions, not a class. Was there some change in how GCC handles
template classes between 3.3 and 4?
template <class T> void TArrayOfObj<T>::setArrayLength( long
lElements )
{
long currentLen = arrayLength();
if (lElements < currentLen)
deleteObjs(len, currentLen - len);
pOiArray->SetLen(lElements);
if (lElements > currentLen)
constructObjs(currentLen, lElements - currentLen);
}
I'd always start by preprocessing my source and seeing if some
"helpful" header file was defining 'len" as a macro or global
constant. One never knows.
the general answer to your question is that yes, gcc 4.x has stricter
adherence to the C++ standard, which often makes loosely-written code
break. If you are correct in saying that this shouldn't compile, and
it doesn't, then gcc 4 is behaving correctly, right?
Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden