我编译&使用macports安装了gcc4.4。std ::线程错误(线程不是std的成员)
当我尝试使用编译 - >克++ -g -Wall -ansi -pthread -std =的C++ 0x的main.cpp ...:
#include <thread>
...
std::thread t(handle);
t.join();
....
编译器返回:
cserver.cpp: In member function 'int CServer::run()':
cserver.cpp:48: error: 'thread' is not a member of 'std'
cserver.cpp:48: error: expected ';' before 't'
cserver.cpp:49: error: 't' was not declared in this scope
但std::cout <<...
编译好..
任何人都可以帮我吗?
如果您在螺纹头看,它似乎该类只存在'#如果定义(_GLIBCXX_HAS_GTHREADS)&&定义(_GLIBCXX_USE_C99_STDINT_TR1)' 。我不确定,但是你必须做些什么才能定义这些定义。 – UncleBens 2010-03-25 22:46:30
@UncleBens:我相信这些是直接由-pthread和-std = C++ 0x定义的。省略-pthread导致段错误:http://gcc.gnu.org/ml/gcc-help/2009-04/msg00208.html – 2010-03-26 03:47:26
只是最新的更新:MacPorts gcc 4.7.0支持/编译std :: thread,而4.6.3没有。 – 2012-04-26 09:45:59