VS C ++声明的即时窗口 [英] VS Immediate Window for C++ Declarations

查看:206
本文介绍了VS C ++声明的即时窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我发现可以在调试时在Visual Studio立即窗口中声明变量.此功能非常有用,因为如果我要在这种情况下尝试代码,则可以创建新变量而无需在新窗口中修改实际代码,然后可以在监视窗口中浏览它们.

Recently I discovered that it's possible to declare variables in the Visual Studio immediate window while debugging. This feature is really useful because if I want to experiment with the code in that context, I can create new variables without modifying the real code in the new window, and I can then explore them in the watch window.

这对于我一直在调试的C#项目非常有用,但是现在我正尝试在其他项目中对基本C ++声明执行相同的操作.我在断点处中断,然后在立即窗口中键入以下内容:

This works great for a C# project I have been debugging, but now I'm trying to do the same thing for a basic C++ declaration in a different project. I break at my breakpoint, and type the following into the immediate window:

int myVariable;

这给出了错误:

CXX0013: Error: missing operator

要使它与C ++项目一起工作,是否需要采取任何步骤?

Are there any steps that I need to get this to work with a C++ project?

推荐答案

您可以通过在调试器中停止时将新变量添加到代码窗口(而不是立即窗口)中来实现相同的功能.

You can accomplish the same functionality by adding the new variable to your code window (rather than immediate window) while stopped in the debugger.

确保已选中工具->选项->调试->编辑并继续->启用本机编辑并继续.

int myVariable=444;

然后添加您的代码, Debug->应用代码更改" ,它可以正常工作. (可选)使用设置下一条语句将执行点移到另一行.

Then add your code, Debug->Apply Code Changes, and it works. Optionally use Set Next Statement to move the execution point to a different line.

这篇关于VS C ++声明的即时窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆