我正在尝试编译一个gRPC服务器,但是我得到了错误:
In file included from /usr/include/c++/4.8.2/mutex:42:0,
from /usr/include/c++/4.8.2/condition_variable:39,
from /home/msl/maum/include/grpc++/server.h:22,
from wavenet_server.cc:2:
/usr/include/c++/4.8.2/functional: In instantiation of ‘struct std::_Bind_simple<std::_Mem_fn<void* (WavenetServiceImpl::*)(void*)>(void**)>’:
/usr/include/c++/4.8.2/thread:137:47: required from ‘std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void* (WavenetServiceImpl::*)(void*); _Args = {void* (&)[2]}]’
wavenet_server.cc:317:73: required from here
/usr/include/c++/4.8.2/functional:1697:61: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void* (WavenetServiceImpl::*)(void*)>(void**)>’
typedef typename result_of<_Callable(_Args...)>::type result_type;
^
/usr/include/c++/4.8.2/functional:1727:9: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void* (WavenetServiceImpl::*)(void*)>(void**)>’
_M_invoke(_Index_tuple<_Indices...>)
我猜是wavenet_server.cc
中的这一行
std::thread t(&WavenetServiceImpl::threadWavenetInfer, thread_args);
引入歧义(编译器不知道这是函数解氯还是表达式?)
所以我试着用:
std::thread t{&WavenetServiceImpl::threadWavenetInfer, thread_args};
但这也行不通。
这是问题的正确根源吗?我该怎么解决呢?如果这行不是问题,那么请让我知道(源代码太长,无法粘贴,我无法分辨哪一行是问题,因为我无法理解错误消息,但我会尽力)。
发布于 2018-10-04 12:20:10
如果要使用C++11功能(如std::result_of
),则需要更新GCC版本。GCC 4.8只有非常实验性的C++11支持。一般建议只在C++98模式下使用它。
如果您想在RedHatEnterpriseLinux7上使用C++11,您应该获得的最新版本:
对于CentOS,DTS可通过软件集合站点获得。
请记住,由于DTS的工作方式,您需要使用DTS编译所有C++11代码,因此不能使用预编译的gRPC库。
https://stackoverflow.com/questions/52645571
复制相似问题