这是我的基本提升代码
#include <iostream>
#include <boost/thread.hpp>
using namespace boost;
using namespace boost::this_thread;
using namespace std;
// Global function called by thread
void GlobalFunction()
{
for (int i=0;i<10;++i)
{
cout << i << "Do something in parallel with main method." << endl;
boost::this_thread::yield();
}
}
void GlobalThreadTest()
{
boost::thread t(&GlobalFunction);
for (int i = 0; i<10; ++i) {
cout << i << "Do something in main method. " << endl;
}
}
int main(int argc, const char * argv[])
{
GlobalThreadTest();
return 0;
}
我从xcode那里得到了很多这样的错误
(null):“boost :: this_thread :: yield()”,引自: (null):“boost :: detail :: thread_data_base :: ~thread_data_base()”, 引自:(null):“boost :: system :: system_category()”, 引自:(null):“boost :: system :: generic_category()”, 引用自:(null):“boost :: thread :: start_thread()”,引用 从:
我已经使用macports安装了boost,并且xcode中的头部搜索路径设置为 /选择/本地/包括/ 这包含所有.hpp文件。
2个问题
感谢。