尝试编译时出现 Boost 线程 c2064 错误
Boost thread c2064 error when trying to compile
我对堆栈溢出很陌生,实际上这是我的第一篇文章,所以大家好。因此,让我们进入正题。使用提升库线程版本 1.54.0使用 VS2010 32 位 - 专业版我已经为提升线程构建了库,在 VS C++设置中不使用预编译标头,将库链接到项目,这是代码
#include <boostthreadthread_only.hpp>
#include <iostream>
#include <conio.h>
#pragma comment(lib, "libboost_thread-vc100-mt-gd-1_54.lib")
#define BOOST_LIB_NAME libboost_thread-vc100-mt-gd-1_54.lib
struct callable
{
void blah();
};
void callable::blah()
{
std::cout << "Threading test !n";
}
boost::thread createThread()
{
callable x;
return boost::thread(x);
}
int main()
{
createThread();
_getch();
return 0;
}
在所有这些之后,我收到此错误
Error 1 error C2064: term does not evaluate to a function taking 0 arguments ....boost_1_54_0boostthreaddetailthread.hpp 117 1 BoostTrial
你能帮我让这个例子工作吗?我使用此示例的原因是因为我有另一个应用程序,该应用程序的设置方式完全相同,但由于此错误而无法正常工作:-(我的目标是让多线程工作,然后我可以从那里获取它。谢谢你的时间。
您需要在callable
中实现operator()
。
不要忘记join()
或detach()
线程以防止程序异常终止。
有关更多示例,请参阅boost::thread
教程。
#include <boostthreadthread_only.hpp>
#include <iostream>
#pragma comment(lib, "libboost_thread-vc100-mt-gd-1_54.lib")
using namespace boost;
struct callable
{
void operator()()
{
std::cout << "Threading test !n";
}
};
boost::thread createThread()
{
callable x;
return boost::thread(x);
}
int main()
{
boost::thread th = createThread();
th.join();
}
示例与std::thread
;
相关文章:
- BOOST线程:线程还是进程
- 如何解决传递给boost线程的函数中的歧义
- cpp 为什么 boost::线程内部的循环不遍历所有值并且推送相同的值?
- C 从类的构造函数运行Boost线程
- 重新分配独立的boost ::线程安全吗?
- Boost::线程如何在主线程和工作线程之间同步
- 链接Boost线程库
- BOOST ::线程内会成员功能调用返回unique_lock Instantiation错误
- Boost ::线程何时终止?如何管理Boost ::线程
- 链接到boost ::线程失败
- 在C 中处理Boost线程条件
- Poco任务管理器/Boost线程混合和匹配
- 创建一个 boost::线程 带有 boost::bind() 或不带
- 为不受支持的平台调整Boost线程/进程
- 删除boost ::线程后代
- 我需要在Boost线程功能中调用Unlock()
- C OPENCV图像在Boost线程中不显示
- boost ::线程在删除可加入线程时存在什么问题
- 增强异步插座和Boost ::线程
- 如何使boost ::线程入睡