Re: [GD-General] Variables scope
Brought to you by:
vexxed72
|
From: Jorrit T. <Jor...@uz...> - 2004-02-04 09:46:52
|
CAVEY GERARD wrote:
>Hi there
>
>Few days ago i switched to Visual c++ 6.0 and this is what i discovered.
>The compiler accept the following C++ code :
>
>//first loop
> for(unsigned long b=0;b<MeshesArray[current].VerticesCount;b++)
> {
> ...//processing
> }
>//second loop
> for( b=0;b<not_used*3;b++)
> {
> ...
> }
>
>But i thiink i should write the second FOR like this "for(unsigned long
>b=0;b<not_used*3;b++)" (i mean i should redeclare 'b' because it came out of
>scope)
>When i tried the compiler answered me "error redefinition ..." !!!
>Did i forget to set an option ;it is a bit strange isn t it?
>
>Greetings
>GC
>
>
The best way to avoid this bug in VC 6 is to put 'unsigned long b'
before the first
loop like this:
unsigned long b;
for (b = 0 ; ...)
...
for (b = 0 ; ...)
We had the same problem in Crystal Space.
Greetings,
|