【问题标题】:Conditional break point on attributes in Visual Studio 2010Visual Studio 2010 中属性的条件断点
【发布时间】:2015-11-28 05:40:34
【问题描述】:

我正试图弄清楚如何在我的代码中设置更复杂的断点。
我想对特定值进行中断(例如,当我的结构的第一个字段等于 42 时中断)

struct SpecificKey
{
    int myFirstField;
    int mySecondField;
};

int Get(const SpecificKey& key)
{
    // <--- set conditional break point if key.myFirstField==42
    //
    // Look for value somewhere...
    //

    return 0;
}

int main()
{
    int value = Get({42, 56});
    return 0;
}

我在 Visual Studio 2010 中尝试过,但它无法与 key.myFirstField==42 正确断开

可以实现吗?如果有,怎么做?

【问题讨论】:

  • 在 VS 2015 社区版中运行良好。

标签: c++ visual-studio visual-studio-2010 debugging breakpoints


【解决方案1】:

如果您只是正确地创建/初始化对象,则可以在 VS 2010 中正常工作:

int main()
{
    SpecificKey myKey;
    myKey.myFirstField = 41; // ...=42;
    myKey.mySecondField = 11;
    int value = Get(myKey);
    return 0;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多