【发布时间】:2017-01-09 17:01:29
【问题描述】:
我想在 test2 为真时中断。它不会让我在 test2 设置为 true 的条件内设置断点。因此,我尝试在声明 test3 的位置下方放置一个条件断点:
string teststring = "debug";
bool threedistinct = false;
bool test2 = false;
if(teststring.find("d") != string::npos)
threedistinct = true;
if(threedistinct)
test2 = true;
bool test3 = false;
我不明白 test2 怎么可能是未定义的。我尝试将其类型更改为 int,将其初始化为 1,并在条件中更改其值,但我得到了相同的错误。注意:错误仅在我尝试设置断点时出现。
【问题讨论】:
-
如果您能包含minimal reproducible example,那就太好了,这样我们也可以尝试并重现您的问题。
-
添加
test2变量后,您是否保存了文件?因为,从屏幕截图来看,您似乎没有保存它。 -
按照指示显示您的minimal reproducible example,而不是sn-p。
-
好的,我会编辑的。
-
您是在发布模式还是调试模式下编译?根据优化级别,可能会去除 test2。
标签: c++ visual-studio scope visual-studio-debugging