the code at the bottom of this post compiles fine but generates an useless binary with
$ clang++ -v
clang version 3.3 (trunk 168461)
Target: x86_64-unknown-linux-gnu
Thread model: posix
when this command is given
clang++ -std=c++11 -pthread -s -O3 -DNDEBUG source.cpp -o source
the binary always generates this
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
Aborted (core dumped)
What I don't get is:
- why i need to link the POSIX threads library if C++11 includes a threading model in the standard, why the flag
-std=c++11
it's not enough ? - if clang++ supports
-pthread
or not, according to what I have read it should support pthreads
Thanks.
#include <iostream>
#include <thread>
void f()
{
std::cout << "Hello World\n";
}
int main()
{
std::thread t(f);
t.join();
}