On Fri, 28 Feb 2003, Frank Barknecht wrote:
Hallo, guenter geiger hat gesagt: // guenter geiger wrote:
Trying to compile GEM on linux yields problems now:
for (int i=0;i<10;i++) a[i] = b[i]; for (i=0;i<10;i++) a[i] = b[i];
The first line in C++ declares and defines i as a variable local to the loop and its body ("a[i] = b[i];"). i is gone after the loop ends.
In the second line, i is thus not known at all, so this must lead to an error.
_From Daniel's error, it seems, VC++ doesn't define i fully local to the loop. This is wrong, but there's not much we can do about it.
I think the constructs should just not be used this way. Then there will be no problems. It doesn't compile on gcc-2.95 anyhow (with or without the second loop), so we have to declare the variable before the loop and all is fine.
Guenter