开发者

g++4.6 std::thread error on Mac OS-X 10.5

开发者 https://www.devze.com 2023-02-25 03:01 出处:网络
I was trying to test thread library of gcc4.6 on mac OS-X 10.5. I successfully compiled and installed gcc4.6 by macports.

I was trying to test thread library of gcc4.6 on mac OS-X 10.5. I successfully compiled and installed gcc4.6 by macports. But the simplest concurrent hello world program failed. The code is like:

#include <iostream>  
#include <thread>  

void sayhello() {std::cout << "Hello\n";}  
int main(){  
  std::thread t(sayhello);
  开发者_如何学Pythont.join();
}

I tried to compile and used g++ -Wall -std=c++0x test.cpp I got the error:

'thread' is not a member of 'std'

Any idea what cause the problem and how can I fix it? Thanks!


Unfortunately, pthreads implementation as of OSX 10.6.8 lacks some required features for C++0x threads. During configure, gcc detects this and disable support for them. More details at std::thread in MacPorts gcc4.5

0

精彩评论

暂无评论...
验证码 换一张
取 消