For loop iterators in VC6

Started by
7 comments, last by pinacolada 19 years, 8 months ago

int main()
{
    for(int cnt = 0; cnt < 10; cnt++)
    {
        std::cout << "hello" << std::endl;
    }

    for(int cnt = 0; cnt < 10; cnt++)
    {
        std::cout << "hello" << std::endl;
    }

    return 0;
}
I'm having a hard time understanding something. The above code does not compile in VC++ 6.0. This is not what I'm confused about, as I know what a redefinition is. What I am confused about is how this compiles in a lot of other compilers (including .NET). Which one of my thoughts is correct? A. This doesn't compile because VC6 is not 100% std compliant. B. This doesn't compile because the standard doesn't define iterator scope in for loops. Thanks!
- A momentary maniac with casual delusions.
Advertisement
It's a known "bug"
you can get around this by doing this:
#define for if(0){} else for
A
Quote:Original post by keen
It's a known "bug"
you can get around this by doing this:
#define for if(0){} else for


Or you could just wrap curly brackets around the second for loop.

Or don't be lazy, and take the 3 seconds to change the variable name.

Or don't put "int" in front of the variable the second time.

Lots of easy solutions to this one. Stop bitching at Microsoft's compiler (it's one of their better products, along with Notepad), and just get some coding experience.

If you think I sound like a dick right now, just remember that you'll sound the same once you have a few more years experience.
If you're porting a lot of code you dont want to change every foor loop due to a scoping bug. It's a bug beleive it or not, I really like visual c++ 6 but Im not that immature about it's flaws
Quote:Original post by Anonymous Poster
Quote:Original post by keen
It's a known "bug"
you can get around this by doing this:
#define for if(0){} else for


Or you could just wrap curly brackets around the second for loop.

Or don't be lazy, and take the 3 seconds to change the variable name.

Or don't put "int" in front of the variable the second time.

Lots of easy solutions to this one. Stop bitching at Microsoft's compiler (it's one of their better products, along with Notepad), and just get some coding experience.

If you think I sound like a dick right now, just remember that you'll sound the same once you have a few more years experience.


So tell me when I bitched about the compiler or even asked for a coding solution.
- A momentary maniac with casual delusions.
Good discussion about this issue
Quote:Original post by keen
Good discussion about this issue


Thank you. THAT answered my question. It's a std compliance issue with VC6.
- A momentary maniac with casual delusions.
Quote:Original post by Anonymous Poster
If you think I sound like a dick right now, just remember that you'll sound the same once you have a few more years experience.


That's a "no" on that one. Lots of people have both experience and manners. You're just a dick.

This topic is closed to new replies.

Advertisement