watch a static variable 
Author Message
 watch a static variable

Hi all

Can someone please tell how to watch a static variable when I add a
breakpoint to the code below at the first if statement and then when the
breaks drag the static variable Step into the watch window I get the
following message CXX0017: symbol Step not found. Many thanks.

BOOL CMyPropertyPage1::StartUp()

{

static int Step = 0;

if(Step == 0)

{

            SomeFunction();

            Step++;

Quote:
}

else if(Step == 1)

{

            SomeFunction1();

            Step++;

Quote:
}

else if(Step == 2)

{

            SomeFunction2();

            Step0;

Quote:
}
}



Tue, 17 Aug 2004 00:32:47 GMT  
 watch a static variable


Quote:
> Hi all

> Can someone please tell how to watch a static variable when I add a
> breakpoint to the code below at the first if statement and then when the
> breaks drag the static variable Step into the watch window I get the
> following message CXX0017: symbol Step not found. Many thanks.

> BOOL CMyPropertyPage1::StartUp()

> {

> static int Step = 0;

> if(Step == 0)
> {
>             SomeFunction();
>             Step++;
> }
> else if(Step == 1)
> {
>             SomeFunction1();
>             Step++;
> }
> else if(Step == 2)
> {
>             SomeFunction2();
>             Step0;
> }
> }

The scope of Step is the CMyPropertyPage1::StartUp() function. Accordingly,
you should be able to see its value when inside that function but not from
anywhere else. (You can also see it in the Locals window.)

If you can't see the value of Step when inside the function, then I am
mystified. If you are trying to see its value after the function returns,
then you are hoping for too much. The fact that Step retains its value after
the function returns does *not* mean that you should be able to see that
value in the watch window. A variable's storage class (how long it lasts)
and its scope (where it can be accessed from) are distinct (although
somewhat related) properties.

--
Quixote
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)



Tue, 17 Aug 2004 11:21:58 GMT  
 watch a static variable

Quote:
> Can someone please tell how to watch a static variable when I add a
> breakpoint to the code below at the first if statement and then when the
> breaks drag the static variable Step into the watch window I get the
> following message CXX0017: symbol Step not found. Many thanks.

The de{*filter*} can be smart or dumb. If you use a symbol, it is smart. If you
use an address it is dumb. Try this:

Set a breakpoint where your variable is first in scope. Then in the watch
window find its address

    &foo

Once you have the address just dereference it in the watch window. Assuming
you are looking at 4 bytes

    *((LPDWORD)0xnnnnnnnnn)

Regards,
Will



Wed, 18 Aug 2004 10:39:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. watch a static variable

2. How to see a static variable in a watch window

3. Watch a local static variable outside of function?

4. Watching static variables doesnt work in MSVC 4.2 but does in 5.0

5. Variables in Variables / Watch window

6. static functions and non static variables

7. Static variable not instaniated in static library

8. static functions with non-static variables!

9. static local variables vs global variables

10. BUG BUG BUG watch variable

11. TC++ 3.0 Debug, Watching pointer variables

12. Variable data not showing in watch windows

 

 
Powered by phpBB® Forum Software