[Bf-committers] Compiler error with MSVC6 on SG_Tree.cpp
Douglas Toltzman
bf-committers@blender.org
Mon, 17 May 2004 19:12:01 -0400 (EDT)
On Mon, 17 May 2004, Stephen Swaney wrote:
> Douglas Toltzman wrote:
> >
> > For these errors, you'll need to declare x and y one time and remove the
> > declarations in the for (...;...;...) constructs.
> >
> > e.g.
> > Add a line at 271 that reads; "unsigned int x;"
> >
> > Then inside the "for ( unsigned int x ..." remove the "unsigned int".
> > Repeat the "unsigned int" removal for the next "for ( unsigned int x..."
> > line a little further down. What you are seeing is a scoping error.
> >
>
> This compiler is hosed. In C++, the params declared in a
> for loop, like the x in for( int x = 0; ..., are local to
> that for loop.
>
> They have no life outside the loop.
>
Of course you are correct, but in my 12 years of professional C++
development, I've found that there is no really good reason to declare a
variable in a for loop, and it is known to make trouble with some
compilers. Also, the assignment syntax of "<type> <name>(<value>)" is, in
some compilers troublesome. Is there really a good reason to use syntax
that is only going to make trouble for some people, if there is no benefit
in execution speed or legibility?
Douglas Toltzman