是什么区别gcc -pthread和gcc -lpthread它在编译多线程程序中使用?
这段代码有效,还是我的编译器坏了?
#include <future>
#include <iostream>
int main() {
std::cout << "doing the test" << std::endl;
std::promise<bool> mypromise;
std::future<bool> myfuture = mypromise.get_future();
mypromise.set_value(true);
bool result = myfuture.get();
std::cout << "success, result is " << result << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
$ g++-mp-4.8 -std=c++11 test.cpp
$ ./a.out
doing the test
Segmentation fault: 11
$
Run Code Online (Sandbox Code Playgroud)
我正在使用g ++ - mp-4.8,这是来自macports的gcc 4.8.
我疯了吗?