C ++ 11线程,错误调用了纯虚函数 [英] C++ 11 Threads, Error Pure virtual function called

查看:110
本文介绍了C ++ 11线程,错误调用了纯虚函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我要编译的非常少的C ++ 11 Thread API代码

here is a very minimal C++11 Thread API code that I am trying to compile

#include<iostream>
#include<thread>

using namespace std;

void threadFunction(void)
{
    cout<<"hello from thread:";//<<this_thread::get_id()<<endl;
}

int main()
{
    std::thread t(threadFunction);
    t.join();

    return 0;
}



关于将其编译为
g ++ thread1.cpp -pthread -std = c ++ 11
我收到以下错误
纯虚拟方法称为 在没有活动异常的情况下调用了terminate
中止



On Compiling this as
g++ thread1.cpp -pthread -std=c++11
I get the following error
pure virtual method called
terminate called without an active exception
Aborted


怎么了,有人可以帮忙吗
请注意,我正在使用ARM A8处理器在Beaglebone Black上进行编译


What wrong, can someone please help
Note that I am compiling this on Beaglebone Black with ARM A8 processor

推荐答案

这是libstdc ++或Clang中的错误,具体取决于您问谁.如果您使用的是2013年10月之后发布的Clang版本,它应该可以工作.运行g++ --version时会看到什么?

This is a bug in either libstdc++ or Clang, depending on who you ask. It should work if you are using a version of Clang released after October 2013. What do you see when you run g++ --version?

作为解决方法,您可以尝试使用此命令行.我不保证它会起作用.请对您的结果发表评论.

As a workaround, you could try using this command line instead. I don't guarantee that it would work; please post a comment with your results.

g++ -pthread -std=c++11 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1,2,4} thread1.cpp

以下是错误报告:

http://llvm.org/bugs/show_bug.cgi?id=12730

这是Clang驱动程序的官方修补程序:

And here's the official fix to the Clang driver:

https://llvm.org/viewvc/llvm-project? view = revision& revision = 191707

我不知道这是否以前也是GCC驱动程序中的错误,和/或是否已修复.

I don't know if this was also previously a bug in the GCC driver, and/or whether it's been fixed.

这篇关于C ++ 11线程,错误调用了纯虚函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆