【问题标题】:Error with Intel C++ compiler: identifier "_Compare" is undefined英特尔 C++ 编译器出错:标识符“_Compare”未定义
【发布时间】:2017-01-18 18:51:07
【问题描述】:

我可以使用以下命令使用 g++ 编译以下 std=c++11 所需的代码:

g++ test.cpp -std=c++11 -Wl,-rpath,/share/apps/gcc/6.3.0/lib64

代码:

#include <chrono>
#include <map>
#include <memory>
#include <thread>
#include <utility>
int main() {
  typedef std::unique_ptr<int> intPointer;
  intPointer p(new int(10));
  std::map<int, std::unique_ptr<int>> m;
  m.insert(std::make_pair(5, std::move(p)));
  auto start = std::chrono::system_clock::now();
  if (std::chrono::system_clock::now() - start < std::chrono::seconds(2))
  {
      std::thread t;
  }
}

相同的命令(可能我不知道正确的命令)不适用于 intel 编译器:

icpc test.cpp -std=c++11 -Wl,-rpath,/share/apps/intel/2016.1.056/vtune_amplifier_xe_2016.1.1.434111/target/linux64/lib64

错误是:

In file included from /share/apps/gcc/6.3.0/include/c++/6.3.0/map(60),
             from test.cpp(2):
/share/apps/gcc/6.3.0/include/c++/6.3.0/bits/stl_tree.h(1437): 
error: identifier "_Compare" is undefined
     && is_nothrow_move_assignable<_Compare>::value)
                                   ^

In file included from /share/apps/gcc/6.3.0/include/c++/6.3.0/map(60),
             from test.cpp(2):
/share/apps/gcc/6.3.0/include/c++/6.3.0/bits/stl_tree.h(1778): 
error: identifier "_Compare" is undefined
  _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
  ^

我做错了什么,我应该如何解决这个问题。

【问题讨论】:

  • 您的英特尔编译器使用 GCC 头文件是否正常?我有一种行不通的感觉。也许您应该使用 Intel 的等价物。
  • 好吧,这段代码不是我写的。它是编译更大软件的测试的一部分。如果这段代码没有返回错误,它让我编译。所以改变代码不是我能做的。那是坚实而给定的。
  • 你这么说,但你的编译器不同意。每个供应商都有自己的标准库实现,您不能随意将标头与编译器混合和匹配。
  • _Compare 是该文件中定义的_Rb_tree&lt;_Key, _Val, _KeyOfValue, _Compare, _Alloc&gt; 的模板参数之一,所以肯定是定义的。一个怀疑是英特尔编译器可能不知道 is_nothrow_move_assignable 最近添加到 type_traits 中。可能需要提交错误报告。
  • @tadman 这完全正常。 ICC 搭载平台编译器的标准库实现(GCC 用于 Linux,MSVC 用于 Windows)。它没有自己的标准库实现。

标签: c++ c++11 intel icc


【解决方案1】:

来自上面的 cmets:

_Compare 是该文件中定义的_Rb_tree&lt;_Key, _Val, _KeyOfValue, _Compare, _Alloc&gt; 的模板参数之一,所以肯定是定义的。

更可能的原因是英特尔编译器可能不知道最近添加到 type_traits 中的 is_nothrow_move_assignable。

【讨论】:

    【解决方案2】:

    我有一个用户在使用 gcc-6.3.0 头文件和 Intel 16.1.150 编译器时遇到了类似的 c++ 困难。我选择了编译器错误理论,尝试使用 Intel 17 编译器并且一切正常。 -道格

    【讨论】:

      【解决方案3】:

      好吧,我与 Intel 代理进行了检查,结果发现 Intel 16 不支持 gcc6.3,支持来自 Intel 17。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-28
        • 2020-02-05
        相关资源
        最近更新 更多