【问题标题】:how to achieve std:map in C++ v60? [duplicate]如何在 C++ v60 中实现 std:map? [复制]
【发布时间】:2021-04-02 16:43:57
【问题描述】:

我正在尝试在 C++ -V60 构建工具中实现 Dictionary 类型的操作。我在 C++ 中找到了 Dictionary 泛型类型的替代方案。但是在尝试实现它时,我在声明地图变量时遇到了问题。

#include <iterator>
#include <map>
using namespace std;

int main()
{
    // insert single values
    map<int, int> m1;
}

错误:

'std::reverse_bidirectional_iterator<std::_Tree<int,std::pair<int const ,int>,std::map<int,int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >::const_iterator,std::pair<int const ,int>,std::pair<int const ,int> const &,std::pair<int const ,int> const *,int>' : identifier was truncated to '255' characters in the debug information

【问题讨论】:

  • 这应该只是一个警告,所以你应该能够继续前进。如果您不想查看使构建诊断信息混乱的消息,请在文件顶部添加 #pragma warning(disable: &lt;warning code number&gt;)
  • Visual C++6,我怀疑。不得不使用白垩纪的工具很糟糕,但根据 Thomas Wolfe 的说法,人类生来就是为了生存、受苦和死亡,而降临在他身上的是悲惨的命运。
  • @user4581301 VC60 编译器架构实际上是 pre-STL(和 pre-ISO 标准),它还没有为这种结构做好准备。它实现了基于 HP 版本的 STL,但即便如此,它也会生成这些消息。编译器也有奇怪的运算符行为(由于预标准重载选择)和初始化。
  • 我想问你的经理一个不同的问题:如果免费提供最先进的编译器,还有什么理由坚持使用石器时代的编译器?我知道我自己的企业遗留代码的情况。在某一时刻,保持旧的东西活着比扔掉它并编写新的东西或者至少维护和现代化代码更昂贵。跨界不是很容易辨认,但20年左右,应该会通过。 ;-)
  • 更不用说编译器已脱离 Microsoft 的支持,因此可能包含安全漏洞

标签: c++ visual-c++-6


【解决方案1】:

您必须在包含头文件之前禁用警告,例如

#pragma warning(disable: 4786)

警告 4786 是链接器警告,因此您已将 /IGNORE:4786 之类的内容添加到命令行中的开关列表中

【讨论】:

    猜你喜欢
    • 2012-04-03
    • 2013-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-20
    • 1970-01-01
    • 2016-07-21
    • 2020-04-11
    相关资源
    最近更新 更多