Farid Zaripov wrote:
-----Original Message-----
From: Martin Sebor [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 22, 2006 8:02 PM
To: [email protected]
Subject: Re: Windows infrastructure for generating
VisualStudio projects and solution(s)
The problem is not with the linking of the library, it comes
up when compiling library headers that make assumptions about
the scope of the for loop's controlling variable. Consider
this algorithm defined in some public library header (i.e.,
one that can be included by a program, such as <algorithm>):
inline void
some_algorithm (int __nloops)
{
for (int __i = 0; __i != __nloops; ++__i)
do_something (__i);
for (int __i = 0; __i != __nloops; ++__i)
do_something_else (__i);
}
The algorithm will compile with no errors or warnings when
the /Zc:forScope is used but will cause a diagnostic when it's not.
I have been tested this example with MSVC 7.1 with Warning Level 4
(highest possible) and haven't any diagnostics (warnings) :)
Well that's probably because MSVC is too broken to detect even
violations of its own conformance violations. Here's the output
from HP aCC 3.10 for the function above:
$ aCC -V -c t.cpp
aCC: HP ANSI C++ B3910B A.03.10
Error 173: "t.cpp", line 7 # Redefined symbol '__i'; previously defined at
["t.cpp", line 4].
for (int __i = 0; __i != __nloops; ++__i)
^^^
[...]
The warning issued at the line with do_something_else (__i); in the
following case:
inline void
some_algorithm (int __nloops)
{
int __i = 5;
for (int __i = 0; __i != __nloops; ++__i)
do_something (__i);
do_something_else (__i);
}
warning C4288: nonstandard extension used : '__i' : loop control
variable declared in
the for-loop is used outside the for-loop scope;
it conflicts with the
declaration in the outer scope
definition of outer scope '__i' used
definition of for-loop scope '__i' ignored
Right, that's the same thing. If the compiler was consistent it
would either warn about both case or neither.
Martin