使用 Microsoft Visual C 进行调试2010 Express(免费版)
我有 C 代码,正在使用 MS-Visual C++ 2010(免费版本)进行调试。在代码中,一些变量在由括号定义的局部范围代码块内声明和使用{... }
但是,在调试时,即使代码执行点位于代码块内部,调试器也不会在监视窗口中显示此代码块内声明的所有变量的值。它显示“错误:未找到符号”。这对我调试这段代码来说是一个很大的障碍。
当我通过从 {}
代码块中删除将一个特定此类变量的声明移至函数开头时,调试器能够正确显示其值。
这种奇怪行为的原因是什么?这是免费版本造成的吗?
在不进行代码更改、使用某些项目设置等的情况下,如何在调试器监视窗口中查看此类本地代码块作用域变量的值?
I have C code which I am debugging using MS-Visual C++ 2010 (free version). In the code some variables are declared and used inside a local scope code block which is defined by parenthesis{... }
But while debugging the debugger does not show the values in watch window, for all the variables which are declared inside this code block, even when the code execution point is inside the code block. It says "Error : symbol not found". this is very much a handicap for me while debugging this code.
When I move the declaration of one particular such variable to beginning of the function, by removing from the {}
code block , the debugger is able to show me its values properly.
What is the reason for this quirky behaviour? Is it the free version causing this?
Without making code changes, using some project settings etc, how can I see the values of such local code block scope variables in debugger watch window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里回复是因为我没有看到这个问题在任何地方得到解决。
转到项目属性页并查看 C/C++ 部分中的 Optimization 属性。如果启用优化,您的一些变量就会被优化掉。
当这种情况发生时(这很常见),没有可供检查的变量,因此您会收到错误消息“未找到符号”,并且它不会显示在本地窗口或自动窗口中。将 Optimization 属性更改为“Disabled”,重新构建,看看问题是否解决。可能会的。
如果优化对您的项目很重要,我会在关闭优化的情况下进行开发,但将其设置回您想要定期测试的值。有时打开优化会破坏某些东西,如果发生这种情况,您想了解最近更改了什么,因为否则很难找到问题。
Replying here because I don't see this problem addressed anywhere.
Go to your project property page and look at the Optimization property in the C/C++ section. If optimization is on, some of your variables are getting optimized away.
When this happens - and it's pretty common - there is no variable to inspect, so you get the error message "symbol not found", and it won't show up in your locals or auto window. Change the Optimization property to Disabled, rebuild, and see if the problem is solved. It probably will be.
If optimization is important to your project, I'd do my development with it turned off, but set it back to what you want periodically to test. Sometimes turning optimization on will break something, and if that happens you want to have some idea of what you've changed lately, because otherwise it can be real hard to find the problem.