在 Visual Studio 2015 中检查 STL 容器

2021-12-22 00:00:00 visual-c++ c++ stl visual-studio-2015

我运行的是 Visual Studio Enterprise 2015,版本 14.0.23107.0 D14REL.

I'm running Visual Studio Enterprise 2015, version 14.0.23107.0 D14REL.

在调试 C++ 程序时,我看不到 STL 容器的内容.

When debugging a C++ program I cannot see the contents of STL containers.

我已取消选中在变量窗口中显示对象的原始结构"选项(工具->选项->调试->常规).

I've got the "Show raw structure of objects in variables windows" option unchecked (Tools->Options->Debugging->General).

以下是说明问题的示例:

Here's an example that illustrates the problem:

#include <list>
#include <string>
#include <vector>

int main()
{
    std::string string = "test";
    std::vector<int> vector{ 4, 5, 6 };
    std::list<std::string> list{ "one", "two", "three" };
    return 0;
}

在 Locals 或 Watch 窗口中,我看到以下内容:

In the Locals or Watch windows I see the following:

list         [...]()
vector       [...](...
  (error)    0
  (error)    0
string       {npos=4294967295}
  (error)    0
  (error)    0

如果我然后选中显示原始结构..."选项,我可以正确地深入到向量和字符串对象,但仍然不是列表!

If I then check the "Show raw structure..." option, I can correctly drill down into the vector and string objects, but still not the list!

是否还有其他选项我错过了,或者这是 VS 中的真正错误?

Is there another option that I've missed, or is this a genuine bug in VS?

推荐答案

我遇到了同样的问题.

您需要进入工具->选项->调试->常规并取消选中使用托管兼容模式"和使用本机兼容模式".

You need to go into Tools->Options->Debugging->General and uncheck both "Use Managed Compability Mode" and "Use Native Compability Mode".

相关文章