函数本地结构会破坏Visual Studio的STL调试可视化工具吗?

时间:2016-10-21 13:09:25

标签: c++ visual-studio visual-studio-2012 stl debuggervisualizer

当struct / class不在函数中时:

#include <vector>
struct Foo { };
int main()
{
    std::vector< Foo > foos;
    return 0;
}

Visual Studio 2012的STL调试可视化工具处理foos就好了:

Name                    Value               Type
-       foos            { size=0 }          std::vector<Foo,std::allocator<Foo> >
            [size]      0                   int
            [capacity]  0                   int
    +       [Raw View]  0x0026fbcc {...}    std::vector<Foo,std::allocator<Foo> > *

但是当Foo位于main()内时:

#include <vector>
int main()
{
    struct Foo { };
    std::vector< Foo > foos;
    return 0;
}

调试器吐出垃圾(?)类型/值,看起来像名称错误严重错误:

Name                                                                                                            Value                                                                           Type
-       foos                                                                                                    {...}                                                                           std::?$vector@UFoo@?1?main@V?$allocator@UFoo@?1?main@@std@@
    -       std::?$_Vector_alloc@$0A@U?$_Vec_base_types@UFoo@?1?main@V?$allocator@UFoo@?1?main@@std@@@std@@     {...}                                                                           std::?$_Vector_alloc@$0A@U?$_Vec_base_types@UFoo@?1?main@V?$allocator@UFoo@?1?main@@std@@@std@@
        -       std::?$_Vector_val@U?$_Simple_types@UFoo@?1?main@@std@@                                         {_Myfirst=0x00000000 {...}  _Mylast=0x00000000 {...} _Myend=0x00000000 {...} }  std::?$_Vector_val@U?$_Simple_types@UFoo@?1?main@@std@@
                    std::_Container_base0                                                                       {...}                                                                           std::_Container_base0
                    _Myfirst                                                                                    0x00000000 {...}                                                                main::__l2::Foo *
                    _Mylast                                                                                     0x00000000 {...}                                                                main::__l2::Foo *
                    _Myend                                                                                      0x00000000 {...}                                                                main::__l2::Foo *

两个问题:

  • 这里发生了什么事?
  • 任何修复/解决方法? (...除了明显的“移动Foomain()”)

0 个答案:

没有答案