Skip to content

编译be出错,重复定义struct std::hash<__int128> #14

Closed

Description

@crcc

编译be时报错

In file included from /home/crc/palo/be/src/runtime/decimal_value.h:34:0,
from /home/crc/palo/be/src/udf/udf.cpp:27:
/home/crc/palo/be/src/util/hash_util.hpp:303:8: error: redefinition of ‘struct std::hash<__int128>’
struct hash<__int128> {
^~~~~~~~~~~~~~
In file included from /usr/include/c++/6/bits/basic_string.h:5643:0,
from /usr/include/c++/6/string:52,
from /usr/include/c++/6/bits/locale_classes.h:40,
from /usr/include/c++/6/bits/ios_base.h:41,
from /usr/include/c++/6/ios:42,
from /usr/include/c++/6/ostream:38,
from /usr/include/c++/6/iostream:39,
from /home/crc/palo/be/src/udf/udf.cpp:23:
/usr/include/c++/6/bits/functional_hash.h:153:3: error: previous definition of ‘struct std::hash<__int128>’
_Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0)
^

我使用的是debian stretch(当前的stable版本),gcc version 6.3.0 20170516 (Debian 6.3.0-18)
gcc -print-prog-name=cc1plus -v的结果如下
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/6/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/6
/usr/include/x86_64-linux-gnu/c++/6
/usr/include/c++/6/backward
/usr/lib/gcc/x86_64-linux-gnu/6/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed
/usr/include
End of search list.

手动把be/CMakeLists.txt中的CLANG_BASE_FLAGS设置如下
set(CLANG_BASE_FLAGS
"-I/usr/include/c++/6/"
"-I/usr/include/x86_64-linux-gnu/c++/6")

Activity

  1. imay commented on Aug 16, 2017

    @imay
    Contributor

    看样子应该是GCC6支持了struct hash<__int128>,应该可以通过宏定义来把hash包起来
    欢迎提PR。

  2. crcc commented on Aug 16, 2017

    @crcc
    Author

    c++不熟,不知道hash用在哪里

    g++ 定义的hash如下,只是简单的cast
    // Explicit specializations for integer types.
    #define _Cxx_hashtable_define_trivial_hash(_Tp)
    template<>
    struct hash<_Tp> : public __hash_base<size_t, _Tp>
    {
    size_t
    operator()(_Tp __val) const noexcept
    { return static_cast<size_t>(__val); }
    };

    用这个靠谱吗?还是要用你们定义的?

  3. added
    kind/fixCategorizes issue or PR as related to a bug.
    on Aug 16, 2017
  4. imay commented on Aug 16, 2017

    @imay
    Contributor

    这个hash函数用在了std::unordered_map中,如果你没法提交的话,可以简单注释掉我们自己实现的hash看看能否编译通过

  5. added this to the 0.9.0 milestone on Aug 16, 2017
  6. morningman commented on May 14, 2019

    @morningman
    Contributor

    Not a problem anymore, using docker dev environment instead

  7. 161 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/fixCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions