Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 编译代码块12.11中的线程程序时出错_C++_C++11_Codeblocks - Fatal编程技术网

C++ 编译代码块12.11中的线程程序时出错

C++ 编译代码块12.11中的线程程序时出错,c++,c++11,codeblocks,C++,C++11,Codeblocks,我的线程程序是: #include<iostream> #include<thread> using namespace std; void t() { cout<<"from thread\n"; } int main() { thread i(&t); cout <<"from main\n"; i.join(); } 我如何解决它?我正在使用windows和代码块12.11,我也有同样的问题。不幸的是,Blocks

我的线程程序是:

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

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

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

我如何解决它?我正在使用windows和代码块12.11,我也有同样的问题。不幸的是,Blocks使用的GCC代码版本不支持所需的C++11功能。打开选项
-std=c++0x
只会将编译器升级到新标准的较新版本。这意味着您将只启用对C+11的基本支持。

您使用的是哪种编译器?抱歉,无法理解youCodeBlocks是一个IDE,它使用编译器。我知道它支持不同的编译器,所以我想知道您使用的是哪种编译器。哦,明白了,我使用的是mingw gcc 4.7编译器当我在Linux上编译上述代码时,如果我忘记将-std=c++0x文件添加到我的g++编译器中,我会收到您的错误。但如果我添加该文件,它将编译得完美无缺。请注意,我也在您的错误前面得到另一个消息,这说明了要做什么:从Test.CPP:2:/Ur/Cube/C++/Buts/C++0xYAdvult.H::32:2:错误:这个错误需要对即将到来的ISO C++标准C++ C++ C++进行编译器和库支持。此支持目前处于试验阶段,必须使用-std=c++0x或-std=gnu++0x编译器选项启用。@mubir您应该升级到新的编译器。尝试我相信他们有一个更新的编译器。
  1)'thread ' was not declared in this scope 

  2)expected ';' before 'i'

  3)'i' was not declared in this scope