2
我想弄清楚如何使用即将到来的C++版本0x。它应该可以在GCC 4.3+中使用gcc std = gnu ++ 0x选项。如何在Eclipse CDT中使用GCC/G ++编译并运行C++ 0x?
我在Eclipse CDT中使用0x编译的简单线程程序,在std = gnu ++ 0x中添加了Project> properties> C/C++ Build> Settings> Miscellaneous> Other flags。
#include <iostream>
#include <thread>
using namespace std;
void hello()
{
cout << "Hello Concurrent World!" << endl;
}
int main()
{
cout << "starting" << endl;
thread t(hello);
t.join();
cout << "ending" << endl;
return 0;
}
该程序只打印“开始”,并返回0.有谁知道为什么它不运行hello函数线程?
您已经添加了'-pthread'标志,给链接器和编译器? – nos 2010-07-04 17:13:05
不错,向链接器添加-pthread标志并且编译器执行它。非常感谢。 – davidhalldor 2010-07-04 17:17:14
添加此为答案,以便我可以投票! – mmocny 2011-03-03 20:09:41