[Bf-committers] Compiler error with MSVC6 on SG_Tree.cpp

Stephen Swaney bf-committers@blender.org
Mon, 17 May 2004 19:59:47 -0500

Douglas Toltzman wrote:
> 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.  

Interesting.  With a similar amount of experience, I have exactly
the opposite opinion.  There is no reason to expand the scope
of a variable beyond where it is used.  This is one of the
known differences between C and C++.

> 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?

Actually, this is initialization rather than assignment and can
be the only way to set const and reference members of classes.

But let's not turn this into a language-lawyering funboard discussion.

Having supported multi-platform apps under various compilers,
I am not insensitve to the problems.  However, rather than
hearing people grump about someone writing standard C++,
I would expect the users of broken implementations to be
cheerfully raising their hands and saying "Why, yes, I
would be happy to port the code to my brain-dead compiler."

As Aristotle said, "Give me enough #ifdefs and a place to sit,
and I can support anything".

Stephen Swaney