C++ 线程调用期间发生总线错误

C++ 线程调用期间发生总线错误,c++,multithreading,arm,cross-compiling,bus-error,C++,Multithreading,Arm,Cross Compiling,Bus Error,以下代码在rasberry pi mod2系统的Rasbian发行版中导致总线错误 #include <thread> #include <iostream> class bar { public: void startFoo() { std::thread t(&bar::foo, this); //bus error because of this line t.join(); } void foo() { std::cout

以下代码在rasberry pi mod2系统的Rasbian发行版中导致总线错误

#include <thread>
#include <iostream>

class bar {
public:
  void startFoo() {
   std::thread t(&bar::foo, this); //bus error because of this line
   t.join();
  }
  void foo() {
    std::cout << "hello from member function" << std::endl;
  }
};

int main()
{
  bar b;
  b.startFoo();
  return 0;
}
#包括
#包括
分类栏{
公众:
void startFoo(){
std::thread t(&bar::foo,this);//由于此行而导致总线错误
t、 join();
}
void foo(){

std::cout您使用了什么命令来编译这个?您指定了
-pthread
?您指定了
-std=c++11
?未对齐的指针可能会发生总线错误,但我在这里看不到。我使用了ccache arm-linux-gnueabihf-g++进行交叉编译。我用compile命令指定了-std=c++0x和-pthread。这是因为我使用了交叉编译的编译器无效?我现在使用的编译器不是为rasberry pi生成的。但是,在我为rasberry pi使用正确的交叉编译器后,总线错误被删除。我可以添加它作为答案吗?