What is up with devc++4? It will not allow me to use for loops at all it always says that the identifies is undeclared. I can compile my code in the visual stuidio by microsoft, I can compile with the intel compiler, and about 12 others and it works just fine, why won't it work with this one? Only code I can get to compile is hello world BS.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Do you have, by any chance, 2 for loops one after another like this?
for (int i = 0; ...)
{
(...)
}
for (i = 0; ...)
{
(...)
}
If so, that's the problem. ANSI C standard says that when a variable is declared as a for loop argument, its scope is limited to that loop ONLY. It is not available outside[before or after] of the loop. So, in the second for loop, you need to redeclare i, since it doesn't exist anymore.
VC++ has lots of flawed implementation. They probably didn't wanted to add a new specific scope for for loops. Lazy bums... Actually, doing it as the standard says gives an error in VC++: can't redeclare variable i. Just stay away from VC++ =)
If that's not the problem, I dunno, for loops works fine. Any code snippet to help us?
-Karhgath
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What is up with devc++4? It will not allow me to use for loops at all it always says that the identifies is undeclared. I can compile my code in the visual stuidio by microsoft, I can compile with the intel compiler, and about 12 others and it works just fine, why won't it work with this one? Only code I can get to compile is hello world BS.
Do you have, by any chance, 2 for loops one after another like this?
for (int i = 0; ...)
{
(...)
}
for (i = 0; ...)
{
(...)
}
If so, that's the problem. ANSI C standard says that when a variable is declared as a for loop argument, its scope is limited to that loop ONLY. It is not available outside[before or after] of the loop. So, in the second for loop, you need to redeclare i, since it doesn't exist anymore.
VC++ has lots of flawed implementation. They probably didn't wanted to add a new specific scope for for loops. Lazy bums... Actually, doing it as the standard says gives an error in VC++: can't redeclare variable i. Just stay away from VC++ =)
If that's not the problem, I dunno, for loops works fine. Any code snippet to help us?
-Karhgath