【发布时间】:2018-02-26 13:40:51
【问题描述】:
这是我第一次在 C++ 中使用线程,我遇到了一些问题。我收到错误
error: no matching function for call to ‘std::thread::thread(<unresolved overloaded function type>, __gnu_cxx::__alloc_traits<std::allocator<packetInfo> >::value_type*)’
这是我的代码摘录:
std::vector<packetInfo> sentPackets; // global var
void renewIP(struct packetInfo *currentPacket) {
...//code
}
void anotherFuntion() {
...
std::thread renewTimer(renewIP, &(sentPackets[i]));
renewTimer.detach();
...
}
我完全不知道我做错了什么或为什么会出错。
谢谢。
【问题讨论】:
-
我没有尝试编译这段代码,但它显然比问题描述的问题多得多。贴出真实代码。
-
我尝试取消对函数名的引用,但我得到了同样的错误。我将它编译为 -std=c++11
标签: c++ multithreading syntax-error