The Watches window lists all variables and expressions that you have specified to watch while debugging. By default, the Watches window opens automatically whenever you start a debugging session. You can open the Watches window by choosing Window > Debugging > Watches.
If you open the Watches window when a debugging session is running, it closes automatically when you end the debugging session. If you open the window when no debugging session is running, it stays open until you close it.
The information given for each watch includes the variable or expression name, type, and value. If the variable has a control to its left, you can click the control to expand or collapse the object. You can click in the Value cell to edit the value directly in the Watches window.
When you add a new variable or expression to the Watches window, the value of the variable or expression is immediately evaluated and displayed. The value of a watch is based on the current context. As you move through your program code, the Watches window is updated to show the value of the watch for that context.
In some cases, the debugger assigns a pound sign (#) and a number as the variable's value. This number is a unique identifier of the given instance. You can use this identifier to determine if a variable points to the same or to a different instance. You cannot edit this value.
Icon | Description |
---|---|
![]() |
Watch object |
![]() |
Watch pointer |
![]() |
Local variable |
![]() |
Local pointer variable |
![]() |
Static local variable |
![]() |
Static local pointer variable |
![]() |
Field |
![]() |
Pointer field |
![]() |
Static field |
![]() |
Static pointer field |
You can create a new watch by double-clicking <Enter new watch> and typing a variable or expression in the text field that is displayed.
The pop-up menu in the Watches window includes the following items.
Menu Item | Description |
---|---|
New Watch | Enables you to create a new watch. |
Delete | Removes the selected object from the Watches window. |
Delete All | Removes all objects from the Watches window. |
Customize | Opens a dialog box in which you can specify the watch expression. |
See Also | |
---|---|
Creating a C or C++ Watch C and C++ Debugger Windows |