概述
https://coderwall.com/p/rzkw6q
Consider the following code, which uses the C++11 (used to be known as C++0x) thread library:
#include <iostream>
#include <thread>
using namespace std;
void hello_world()
{
cout << "Hello from thread!n";
}
int main()
{
thread t(hello_world);
t.join();
return 0;
}
How can we get this to work? If we compile it with:
We'll get something like:
... and maybe something about the
type used in the code:So we add the
...No errors during compilation, but when we try to execute
...... oops. We have to link this against the operating system's implementation of threads. In linux, this is the
library. The winning command is:and then:
最后
以上就是飘逸鸡翅为你收集整理的c++ std:thread编译出错记录的全部内容,希望文章能够帮你解决c++ std:thread编译出错记录所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复