Microsoft KB Archive/109678

= FIX: CodeView/Visual Workbench Can't Watch static const Member =

Article ID: 109678

Article Last Modified on 12/1/2003

-

APPLIES TO

 Microsoft CodeView 4.0 Microsoft CodeView 4.01 Microsoft CodeView 4.1 Microsoft CodeView 4.0 Microsoft CodeView 4.01 Microsoft CodeView 4.1 The Visual Workbench Integrated Debugger, when used with:  Microsoft Visual C++ 1.0 Professional Edition</li></ul>

<ul> Microsoft Visual C++ 1.5 Professional Edition</li></ul>

<ul> Microsoft Visual C++ 2.0 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q109678

<div class="symptoms_section">

SYMPTOMS
If you try to watch a static const member of a class in CodeView or the Visual Workbench debugger by placing a watch on classname::member, the debugger will display the error

CXX0030 expression not evaluatable

-or-

CXX0017 expression cannot be evaluated

or it will show invalid information. Also, if you try to watch the class that contains the static const member and expand the class to look at the members, the debugger will not display the correct information for the static const member.

<div class="resolution_section">

RESOLUTION
You can work around this by making the member variable static and not const, or by setting a watch on an instance of the class. For example, set the watch on scmemGlobal.scInt in the sample code below.

<div class="status_section">

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

Sample Code
/* Compile options needed: /Zi /Od


 * 1) include <stdio.h>

class CSCMember { public: static const int scInt; static int sInt; const int cInt; public: CSCMember : cInt(4) {}; };

const int CSCMember::scInt= 2; int CSCMember::sInt= 3;

CSCMember scmemGlobal;

void main {   /*    The first line prints the correct value, but you cannot watch the variable in the debugger by placing a watch on   CSCMember::scInt or by watching the members of scmemGlobal. */    printf ("static const member= %d\n", scmemGlobal.scInt); printf ("static member= %d\n", scmemGlobal.sInt); printf ("const member= %d\n", scmemGlobal.cInt); }

Additional query words: 4.00 4.10 1.00 1.10 1.50 2.00

Keywords: kbbug kbfix kbide kbdebug KB109678

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.