• Advertisement
Sign in to follow this  

For loop iterators in VC6

This topic is 4946 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
It's a known "bug"
you can get around this by doing this:
#define for if(0){} else for

Share this post


Link to post
Share on other sites
Guest 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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement