Учитывая простую программу, которая использует C++ 11 функции многопоточной:Здания C++ 11 потоковых перевод-единиц в Linux
#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();
}
Если я построить приложение с помощью:
c++ -std=c++11 Program.cpp -o Program.out
программы строит штраф, но когда я запускаю его, я получаю:
./Program.out
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
Aborted
Если я построить его с -pthread
как в:
c++ -std=c++11 Program.cpp -o Program.out -pthread
программа выполняет штраф. Я не видел никаких других функций C++ 11, которым требуются специальные флаги сборки, почему это происходит?
См. Http://stackoverflow.com/questions/11784153/in-g-is-c-11-thread-model-using-pthreads-in-the-background – wich
См. Http://stackoverflow.com/questions/9945391/stdthread-создание броски-исключение –