【问题标题】:compilation errors only in release mode -- stl vectors仅在发布模式下的编译错误——stl 向量
【发布时间】:2013-09-27 07:43:00
【问题描述】:

我正在尝试构建一个由 3 个 vc 项目文件组成的 c++ 解决方案。我在哪里使用我自己的 stl 库和标准 stl 集合[列表、向量..等],并以适当的命名空间为前缀。

对于一个特定的变量[用户定义类型的向量]。 这是一些用户定义结构的元素,它给出的错误如下:

error C2039: '_Mycont' : is not a member of 'std::_Vector_const_iterator<_Ty,_Alloc>'   C:\Program Files\Microsoft Visual Studio 8\VC\include\vector    195 

error C2039: '_Mycont' : is not a member of 'std::_Vector_const_iterator<_Ty,_Alloc>'   C:\Program Files\Microsoft Visual Studio 8\VC\include\vector    195 

error C2039: '_Mycont' : is not a member of 'std::_Vector_const_iterator<_Ty,_Alloc>'   C:\Program Files\Microsoft Visual Studio 8\VC\include\vector    195 

那行代码是

std::vector<ACand> Cands;

对于上述变量,我正在尝试执行插入和删除等最小操作。

它在调试模式下正常工作。 在发布模式下无法做到这一点。

任何人都可以帮助我解决错误。

谢谢 拉达

【问题讨论】:

    标签: c++ stl visual-studio-2005


    【解决方案1】:

    您永远不应该尝试创建自己的 stl 容器。您的编译器实现提供的那些比您可能实现的任何东西都要好。 但是,如果您仍然想这样做,请在它们前面加上适当的命名空间(如 mystd 或其他东西)。我的猜测是,在发布时,您的程序试图使用 std::vector 而不是 mystd::vector,所以它抱怨因为 std::vector 不包含任何 _Mycont 成员。

    【讨论】:

    • 感谢您的回复。我检查了完整的代码,所有与标准 STL 相关的语句都不是 mystl 前缀错误。
    猜你喜欢
    • 2016-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多