Watching Local Variables That Are Also Globally DeclaredLast reviewed: November 2, 1995Article ID: Q98288 |
The information in this article applies to:
SUMMARYConsider debugging the following program in WinDbg:
int x = 1; int y = 2; void main() { int x = 2; x++; y++; }Notice that there is a global variable x and a local variable x. Before you step into main, if you set watchpoints on x and y, the Watch window will display a value for y but for x will say "Expression cannot be evaluated." To see the value for x, use ::x and x will evaluate to the local x in main once you've stepped into main.
MORE INFORMATIONWhen debugging an application, the X86 C++ evaluator is loaded. Given this, you can use the scope resolution operator in a watch statement to view a hidden global variable. Without the use of the scope resolution operator, there is no way (short of watching it in a memory window) to watch a hidden global variable.
|
Additional reference words: 3.10 3.50 4.00 95
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |