Anonymous
Anonymous

Reputation: 4777

Visual Studio 2013 C++ variable watch does not work

I found a thread of another user on another website with the same problem except he is using Fortran while I am using C++:

https://software.intel.com/en-us/forums/topic/508718

In fact, I can cite her/him:

The problem:

My problem is that in the debug mode the program algorithm works fine except it does not show the values of the variables.

  1. I tried the watch window and also moving mouse over the variable but neither of them works.

  2. I tried very simple codes like Hello World and just defined an integer but the program is unable to show the value of the variable in debug mode.

  3. From time to time the debug mode works correctly. Sometimes I have to restart the debugger 10 times and then it works for 1 time. It does not matter whether I add or remove breakpoints.

My setup:

Windows 7 64 Bit

Visual Studio Ultimate 2013 (from MSDNAA, all original stuff) Version 12.0.30501.00 Update 2.

I have another notebook with Windows 7 64 Bit and the same Visual Studio Version installed -> same problem!

Upvotes: 1

Views: 1029

Answers (2)

Andreas H.
Andreas H.

Reputation: 1811

I have the same problem once in a while and the following steps help me solving it:

Make sure optimizations are deactivated in your Debug build. If they are enabled you compiler removes stack frames, puts variable values into cpu registers or inlines whole functions. The debugger does not like optimizations.

Make sure you use a Debug Runtime Library (check 'Runtime Library' in 'Code generation' and select Multithreaded-Debug or Multithreaded-Debug-DLL)

Rebuild your application (right click Project -> "Rebuild"). Sometimes there are problems which can be solved by a rebuild (i.e. when you update source files from repository which are older then your binaries but newer then the source you built the binaries from; or when you update your compiler or libraries and only parts of your application are rebuild).

Disable Minimal Rebuild in 'code generation' option page. It may mess up you program database.

If everything fails you may try to create a clean new project with default settings and add all your existing .cpp/.h files. This way you make sure your settings are not messed up.

If you are using global variables defined within a namespace you always have to enter the namespace into the watch window (i.e. a variable 'x' defined in namespace 'Y' must be watched as 'Y::x')

Upvotes: 1

Neel Chatterjee
Neel Chatterjee

Reputation: 1

Use getchar(); at the end of the program or at the end of a cout statement. In my experience, I had to use getchar(); multiple times to show the variables and the solution. Try it!

Upvotes: 0

Related Questions