Hi, I am using working on a c++ application in Visual studio 2008 I have built my project with Maximize speed(/o2) (From Properties -> configuration properties -> c/c++ -> optimization -> optimization) Unable to watch the variable values while debugging the code. Pls help.
views:
46answers:
2This is normal. Once you activate optimizations, the compiler pretty much ignores all your variable requests and tries to do what it thinks is best.
There's a reason why the debug builds have no optimizations enabled :)
Edit: You might have some luck with enabling or disabling optimizations for specific bits of code. Try this link: http://msdn.microsoft.com/en-us/library/chh3fb0k(VS.80).aspx
Sometimes resorting to the "disassembly view" of the C++ code and stepping through the optimized release x86 give you an idea of what's going on. Pay special attention to function calls (many times those cannot be optimized out), and code around those calls - before and after, and register usage (many times variables are optimized into hardware registers).
Regardless of whether this works or not, you learn a little bit about x86 assembly, compiler optimization, and how C++ is actually implemented!