CC versios 5.5 to 5.8 codecompatability


 
Thread Tools Search this Thread
Top Forums Programming CC versios 5.5 to 5.8 codecompatability
# 1  
Old 12-12-2012
CC versios 5.5 to 5.8 codecompatability

Hello

Machine A:CC: Sun C++ 5.5 Patch 113817-07 2004/03/23
Machine B:CC: Sun C++ 5.8 2005/10/13

I have compiled a code with same options
/opt/SUNWspro/bin/CC -c -fast -O3 -DSYSTEMV -DCGM attdictionary.C

on both the Machines A,B

on Machine A i could see code successfully compiled
on Machine B it is not it reporting following Error
"attdictionary.C",line 226: Error: count is not defined.


i could see code some thing like this
.....
.....
function()
{

for(int count;count<10;count++)
{
...........
}

if(count<10)--->error coming here
{

}

}

ideally according to the scope rules it should report error but why it is successfully compiled on Machine A not on Machine B

is this due to compiler versions??

Any solution to the problem is helpful and appreciable.Thanks in advance.

Thanks
Revathi R
# 2  
Old 12-14-2012
Yes, it is probably due to compiler versions. Do you know what the default C/C++ standard is for the older and newer versions of the compiler?

According to the C++ (and C99) standard the scope is restricted to the loop, i.e. the variable count should not be visible outside the loop. Best modify your source code so that this misfeature will not bite you again in the future.
# 3  
Old 12-14-2012
Yes... We found it is due to the compiler versions only....

but we colud see many such issues...

we have code in Sun C++ compiler 4.2, we are trying to migrate it to Sun C++ 5.8
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question