Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8945423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:14:34+00:00 2026-06-15T12:14:34+00:00

I have a VC++ 6.0 project which I am now compiling using VS2008 .

  • 0

I have a VC++ 6.0 project which I am now compiling using VS2008 . I have this piece of code that used to compile under VC++ 6 but throws an error under VS2008 :

int CIDStorage::Length()

{

CIDStorage* m_ptr = this;

    for(int i = 0;m_ptr->m_ptrNext != NULL;i++)
        m_ptr = m_ptr->m_ptrNext;

    if(i == 0)
        if(m_ID.IsEmpty())
            return 0;

    return i+1;
}

the error is 'i' : undeclared identifier

No probs with that I can see how that came about . So … Do I change the source code . Or is there a compiler setting I could set that cures this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:14:35+00:00Added an answer on June 15, 2026 at 12:14 pm

    VC++ 6 (normally1) follows a pre-standard rule where a variable defined in a for loop remains defined for the rest of the scope in which that for loop resides. VC++ 2008 follows the standard rule where the for loop defines a new scope, and the variable is defined only within that scope.

    The cure is pretty simple — define the variable outside the loop:

    int CIDStorage::Length()
    {
        CIDStorage* m_ptr = this;
        int i;
    
        for(i = 0; m_ptr->m_ptrNext != NULL; i++)
            m_ptr = m_ptr->m_ptrNext;
    
        if(i == 0)
            if(m_ID.IsEmpty())
                return 0;
    
        return i+1;
    }
    

    1 The compiler in VC++ is actually capable of following the correct rules for scoping of variables defined in a for loop. Unfortunately, to follow the rule, you have to use the /Za flag, which tries to enforce all the rules it knows as strictly as possible. That turns out to be completely unusable because with that turned on, it rejects (virtually?) all of its own headers as containing errors!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now I have a Xcode project which is built for iOS 5, but now
I have a c# (win form) visual studio project which i am now compiling
I have this C++ project which compiles using a Makefile, and sometimes when (
I have a project which fully designed for smart phone and now, I need
ok i have a project which has many gridview in its pages... now i
I am writing a MVC3 project. Right now I have a table which has
I am writing a MVC3 project. Right now I have a table which has
I have a project which uses groovy 1.7.5 and grails 1.3.4. but my new
I have a project which uses php's mt_rand() to generate different random integers but
I have added a piece of sharepoint code to the existing java file which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.