相关疑难解决方法(0)

编译时-pthread和-lpthread之间的差异

是什么区别gcc -pthreadgcc -lpthread它在编译多线程程序中使用?

multithreading gcc pthreads thread-safety compiler-flags

99
推荐指数
3
解决办法
5万
查看次数

std :: promise在我的机器上坏了(使用g ++ - mp)吗?

这段代码有效,还是我的编译器坏了?

#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.

我疯了吗?

c++ gcc future c++11

17
推荐指数
1
解决办法
1511
查看次数