Visual Studio 不将布尔值识别为变量

Visual Studio doesn't recognize boolean as variable

我想在 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,并在条件中更改其值,但我遇到了相同的错误。注意:仅当我尝试设置断点时才会出现错误。

"I was accidentally compiling in max liability mode. I changed to Release to Debug and it works. Thanks!"

很高兴知道您已经解决了这个问题。不过我同意PaulMcKenzie的建议,真正的问题应该是在两种不同模式下的某些设置无法生成调试信息。

(1将生成调试信息的链接器设置。 (2)禁用优化选项。

参考类似问题:

http://www.databasesql.info/article/896010299/