首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Visual Studio中设置基于字符串比较的条件断点?

如何在Visual Studio中设置基于字符串比较的条件断点?
EN

Stack Overflow用户
提问于 2014-02-21 21:18:26
回答 2查看 32.2K关注 0票数 24

这是我多年来不时尝试的东西,但从未完全成功。我只想基于字符串相等为Visual C++ 2012设置一个条件断点。我想测试的变量是

代码语言:javascript
运行
复制
string test;

我试过了

代码语言:javascript
运行
复制
test == "foo"
=> The breakpoint cannot be set. no operator "==" matches these operands

test == string("foo")
=> The breakpoint cannot be set. no operator "==" matches these operands

test.compare("foo") == 0
=> The breakpoint cannot be set. This expression has side effects and will not be evaluated.

strcmp(test.c_str(), "foo") == 0
=> The breakpoint cannot be set. This expression has side effects and will not be evaluated.
EN

Stack Overflow用户

发布于 2014-02-21 21:43:24

您可以使用以下可移植且简单的方法:

代码语言:javascript
运行
复制
if (!test.compare("foo")) {
    int dummy = 0; // any statement, put breakpoint here
}
票数 -3
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21935563

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档