B
Bob Altman
I upgraded a VS 2003 project to VS 2005, and now it gets a compiler error.
What I don't understand is why the code compiled without problems in VS
2003. The problem code, contained in a .cpp file and compiled as C++ (/TP)
is:
for ( int kk=1;kk<3;kk++ )
if ( abs_x_offset <= x_limit[kk] ) break;
// VS 2005 complains that kk isn't defined
float abs_y_limit = ( ( y_limit[kk] - y_limit[kk-1] )
/ ( x_limit[kk] - x_limit[kk-1] ) )
* ( abs_x_offset - x_limit[kk-1] ) + y_limit[kk-1];
I think that the intent of this code is to perform a linear interpolation by
first finding an index (kk) and then performing a calculation using that
value. But kk isn't defined outside of the "for" statement. (There are no
other instances of "kk" anywhere in the code.)
Is VS 2003 somehow making kk visible outside of the "for" statement?
TIA - Bob
What I don't understand is why the code compiled without problems in VS
2003. The problem code, contained in a .cpp file and compiled as C++ (/TP)
is:
for ( int kk=1;kk<3;kk++ )
if ( abs_x_offset <= x_limit[kk] ) break;
// VS 2005 complains that kk isn't defined
float abs_y_limit = ( ( y_limit[kk] - y_limit[kk-1] )
/ ( x_limit[kk] - x_limit[kk-1] ) )
* ( abs_x_offset - x_limit[kk-1] ) + y_limit[kk-1];
I think that the intent of this code is to perform a linear interpolation by
first finding an index (kk) and then performing a calculation using that
value. But kk isn't defined outside of the "for" statement. (There are no
other instances of "kk" anywhere in the code.)
Is VS 2003 somehow making kk visible outside of the "for" statement?
TIA - Bob