c++ - GTEST 中 std::map 和 dense_hash_map 的编译器错误

标签 c++ gcc compiler-errors googletest

当我尝试在我的 GOOGLE 测试中使用我的项目/模块时出现此错误。

gcc.compile.c++ bin/gcc-4.8.3/debug/link-static/gmock_test.o
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
                 from /usr/local/include/google/dense_hash_map:106,
                 from sagarmatha/utils/include/multicast_receiver.h:11,
                 from include/transmitter/mcx_receiver.h:25,
                 from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:130:11: error: redefinition of ‘class std::tuple< <template-parameter-1-1> >’
     class tuple : public _Tuple_impl<0, _Elements...>
           ^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
                 from /usr/include/c++/4.8.2/map:61,
                 from 8k/include/Source.h:12,
                 from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:388:11: error: previous definition of ‘class std::tuple< <template-parameter-1-1> >’
     class tuple : public _Tuple_impl<0, _Elements...>
           ^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
                 from /usr/local/include/google/dense_hash_map:106,
                 from sagarmatha/utils/include/multicast_receiver.h:11,
                 from include/transmitter/mcx_receiver.h:25,
                 from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:164:20: error: redefinition of ‘class std::tuple<>’
   template<> class tuple<> { };
                    ^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
                 from /usr/include/c++/4.8.2/map:61,
                 from 8k/include/Source.h:12,
                 from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:512:11: error: previous definition of ‘class std::tuple<>’
     class tuple<>
           ^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
                 from /usr/local/include/google/dense_hash_map:106,
                 from sagarmatha/utils/include/multicast_receiver.h:11,
                 from include/transmitter/mcx_receiver.h:25,
                 from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:168:11: error: redefinition of ‘class std::tuple<_T1, _T2>’
     class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
           ^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
                 from /usr/include/c++/4.8.2/map:61,
                 from 8k/include/Source.h:12,
                 from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:521:11: error: previous definition of ‘class std::tuple<_T1, _T2>’
     class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
           ^
In file included from /usr/include/c++/4.8.2/tuple:38:0,
                 from /usr/include/c++/4.8.2/bits/stl_map.h:63,
                 from /usr/include/c++/4.8.2/map:61,
                 from 8k/include/Source.h:12,
                 from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/utility:83:24: error: template parameter ‘long unsigned int _Int’
   template<std::size_t _Int, class _Tp>
                        ^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
                 from /usr/local/include/google/dense_hash_map:106,
                 from sagarmatha/utils/include/multicast_receiver.h:11,
                 from include/transmitter/mcx_receiver.h:25,
                 from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:223:12: error: redeclared here as ‘int __i’
     struct tuple_element;
            ^
/usr/include/c++/4.8.2/tr1/tuple:230:12: error: specialization of ‘template<long unsigned int _Int, class _Tp> struct std::tuple_element’ in different namespace [-fpermissive]
     struct tuple_element<__i, tuple<_Head, _Tail...> >
            ^
In file included from /usr/include/c++/4.8.2/tuple:38:0,
                 from /usr/include/c++/4.8.2/bits/stl_map.h:63,
                 from /usr/include/c++/4.8.2/map:61,
                 from 8k/include/Source.h:12,
                 from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/utility:84:11: error:   from definition of ‘template<long unsigned int _Int, class _Tp> struct std::tuple_element’ [-fpermissive]
     class tuple_element;
           ^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
                 from /usr/local/include/google/dense_hash_map:106,
                 from sagarmatha/utils/include/multicast_receiver.h:11,
                 from include/transmitter/mcx_receiver.h:25,
                 from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:237:12: error: redefinition of ‘struct std::tuple_element<0ul, std::tuple<_El0, _El ...> >’
     struct tuple_element<0, tuple<_Head, _Tail...> >
            ^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
                 from /usr/include/c++/4.8.2/map:61,
                 from 8k/include/Source.h:12,
                 from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:687:12: error: previous definition of ‘struct std::tuple_element<0ul, std::tuple<_El0, _El ...> >’
     struct tuple_element<0, tuple<_Head, _Tail...> >
            ^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
                 from /usr/local/include/google/dense_hash_map:106,
                 from sagarmatha/utils/include/multicast_receiver.h:11,
                 from include/transmitter/mcx_receiver.h:25,
                 from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:248:12: error: redefinition of ‘struct std::tuple_size<std::tuple<_Args1 ...> >’
     struct tuple_size<tuple<_Elements...> >
            ^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
                 from /usr/include/c++/4.8.2/map:61,
                 from 8k/include/Source.h:12,
                 from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:737:12: error: previous definition of ‘struct std::tuple_size<std::tuple<_Args1 ...> >’
     struct tuple_size<tuple<_Elements...>>
            ^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
                 from /usr/local/include/google/dense_hash_map:106,
                 from sagarmatha/utils/include/multicast_receiver.h:11,
                 from include/transmitter/mcx_receiver.h:25,
                 from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:254:49: error: definition of ‘std::tuple_size<std::tuple<_Args1 ...> >::value’ is not in namespace enclosing ‘std::tuple_size<std::tuple<_Args1 ...> >’ [-fpermissive]
     const int tuple_size<tuple<_Elements...> >::value;

是否与 map 和 dense_hash_map 一起使用有关?请帮忙?

最佳答案

因为它解决了您的问题,所以我将其作为答案:设置 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=0 以指示编译不使用 tr1 元组或它自己的元组实现。

关于c++ - GTEST 中 std::map 和 dense_hash_map 的编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40255304/

相关文章:

c++ - 有没有办法改变 std::pair 的引用成员指向的位置?

gcc - gcc 是否递归搜索 CPATH?

java - 在java中,我期望返回必须捕获的值的方法调用不会抛出编译错误。为什么?

c - Linux 中多线程的自动使用

objective-c - 使用 GCC 在 Ubuntu 上编译 Objective-C

c++ - 导致编译错误的意外模板实例化

java - 可能的 eclipse 错误

c++ - 如果在没有 move 构造函数的情况下 move 对象会发生什么?

c++ - 查询中的 SQLite Int 到 Hex 和 Hex 到 Int

c++ - 在模板类的模板成员函数中返回模板对象