0

我的线程程序是:

#include<iostream>
#include<thread>
using namespace std;

void t()
{
cout<<"from thread\n";
}

 int main()
 {
 thread i(&t);
 cout <<"from main\n";
 i.join();
  }

但它在代码块中显示以下错误:

  1)'thread ' was not declared in this scope 

  2)expected ';' before 'i'

  3)'i' was not declared in this scope 

我该如何解决?我使用的是 windows 和 codeblocks 12.11

4

1 回答 1

0

我也有同样的问题。不幸的是,GCC Code::Blocks 使用的版本不支持您想要的 C++11 功能。打开该选项-std=c++0x只会将编译器升级到新标准的较新版本。这意味着您将只启用对 C+11 的基本支持。

于 2013-04-15T12:17:48.193 回答