Given a simple program that uses C++11 threading features:
#include <iostream>
#include <thread>
using namespace std;
void dont_thread_on_me() {
cout << "action from another thread" << endl;
}
int main() {
thread t { dont_thread_on_me };
t.detach();
cin.get();
}
If I build the application using:
c++ -std=c++11 Program.cpp -o Program.out
the program builds fine, but when I run it, I get:
./Program.out
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
Aborted
If I build it with -pthread
as in:
c++ -std=c++11 Program.cpp -o Program.out -pthread
the program executes fine. I haven't seen any other C++11 features that require special build flags, why does this one?