FIX: Cannot Evaluate Structures in Classes

ID: Q143050

4.00 WINDOWS NT

The information in this article applies to:

SYMPTOMS

The Visual C++ version 4.0 debugger cannot evaluate structures that are defined and declared inside a class when C7-compatible debugging information is generated.

In the Auto window you will get this error:

   CXX0030: Error: expression cannot be evaluated.

In the QuickWatch window you will get this error:

   CXX0017: Error: symbol "CMyClass::MyStruct" not found.

RESOLUTION

Use the /Zi compiler switch (Program Database) or make the structure definition global.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ 4.1.

MORE INFORMATION

Sample Code to Reproduce Problem

/* Compile options needed: /Z7
*/ 
#include <string.h>

class CMyClass {
    int myInt;

    struct MyStruct
    {
        char string[30];
    };
    MyStruct myStruct;
public:
    CMyClass()
    {
        myInt = 5;
        strcpy(myStruct.string, "Hello");
    }   // Set Break Point here
};

void main()
{
    CMyClass c;
}

Additional query words: kbVC400bug 4.00 4.10 KBCategory: KBSubcategory: WBDebug vcfixlist410

Keywords          : kbDebug kbide kbVC410fix 
Version           : 4.00
Platform          : NT WINDOWS
Solution Type     : kbfix

Last Reviewed: May 15, 1998