When trying to compile the following code
#include <thread>
#include <iostream>
void foo() { std::cout << "foo
"; }
int main()
{
std::thread t(foo);
t.join();
}
I get an error:
C:Test>g++ -g -Wall -lpthread -std=c++0x
main.cpp
main.cpp: In function 'int main()':
main.cpp:12:2: error: 'thread' is not a member of 'std'
main.cpp:12:14: error: expected ';' before 't'
main.cpp:13:2: error: 't' has not been declared
How to use C++11 experimental concurrency features? I have MinGW GCC 4.5.1 (TDM)
EDIT: BTW, Visual Studio 2012 performs good this code sample.
See Question&Answers more detail:os