std :: future示例不使用CodeBlocks

时间:2016-06-17 21:50:31

标签: c++ c++11 std codeblocks

我刚刚在Windows 7上安装了CodeBlocks 16.01,并将其设置为使用C ++ 11支持,如前面的答案read this whole section on the official page of MongoDB中所述。然后我尝试运行给定here的示例代码,并在尝试编译时收到以下错误消息。

 ||=== Build: Debug in MyProgram (compiler: GNU GCC Compiler) ===|
 C:\codeBlocksProjects\MyProgram\main.cpp||In function 'int main()':|
 C:\codeBlocksProjects\MyProgram\main.cpp|8|error: variable 'std::packaged_task<int()> task' has initializer but incomplete type|
 C:\codeBlocksProjects\MyProgram\main.cpp|9|error: variable 'std::future<int> f1' has initializer but incomplete type|
 C:\codeBlocksProjects\MyProgram\main.cpp|10|error: 'thread' is not a member of 'std'|
 C:\codeBlocksProjects\MyProgram\main.cpp|13|error: variable 'std::future<int> f2' has initializer but incomplete type|
 C:\codeBlocksProjects\MyProgram\main.cpp|13|error: invalid use of incomplete type 'class std::future<int>'|
 c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\future|114|error: declaration of 'class std::future<int>'|
 C:\codeBlocksProjects\MyProgram\main.cpp|16|error: aggregate 'std::promise<int> p' has incomplete type and cannot be defined|
 C:\codeBlocksProjects\MyProgram\main.cpp|17|error: variable 'std::future<int> f3' has initializer but incomplete type|
 C:\codeBlocksProjects\MyProgram\main.cpp|18|error: 'thread' is not a member of 'std'|
 c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\future|172|error: 'std::future<typename std::result_of<_Functor(_ArgTypes ...)>::type> std::async(std::launch, _Fn&&, _Args&& ...) [with _Fn = main()::<lambda()>; _Args = {}; typename std::result_of<_Functor(_ArgTypes ...)>::type = int]', declared using local type 'main()::<lambda()>', is used but never defined [-fpermissive]|
 ||=== Build failed: 10 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|

编辑:

构建日志如下。

mingw32-g++.exe -Wall -fexceptions -std=c++11 -g -std=c++11  -c     C:\codeBlocksProjects\MyProgram\main.cpp -o obj\Debug\main.o
C:\codeBlocksProjects\MyProgram\main.cpp: In function 'int main()':
C:\codeBlocksProjects\MyProgram\main.cpp:8:35: error: variable 'std::packaged_task<int()> task' has initializer but incomplete type
 std::packaged_task<int()> task([](){ return 7; }); // wrap the function

输出

 ||=== Build: Debug in MyProgram (compiler: GNU GCC Compiler) ===|
C:\codeBlocksProjects\MyProgram\main.cpp||In function 'int main()':|
C:\codeBlocksProjects\MyProgram\main.cpp|8|error: variable 'std::packaged_task<int()> task' has initializer but incomplete type|
C:\codeBlocksProjects\MyProgram\main.cpp|9|error: variable 'std::future<int> f1' has initializer but incomplete type|
C:\codeBlocksProjects\MyProgram\main.cpp|10|error: 'thread' is not a member of 'std'|
C:\codeBlocksProjects\MyProgram\main.cpp|13|error: variable 'std::future<int> f2' has initializer but incomplete type|
C:\codeBlocksProjects\MyProgram\main.cpp|13|error: invalid use of incomplete type 'class std::future<int>'|
c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\future|114|error: declaration of 'class std::future<int>'|
C:\codeBlocksProjects\MyProgram\main.cpp|16|error: aggregate 'std::promise<int> p' has incomplete type and cannot be defined|
C:\codeBlocksProjects\MyProgram\main.cpp|17|error: variable 'std::future<int> f3' has initializer but incomplete type|
C:\codeBlocksProjects\MyProgram\main.cpp|18|error: 'thread' is not a member of 'std'|
c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\future|172|error: 'std::future<typename std::result_of<_Functor(_ArgTypes ...)>::type> std::async(std::launch, _Fn&&, _Args&& ...) [with _Fn = main()::<lambda()>; _Args = {}; typename std::result_of<_Functor(_ArgTypes ...)>::type = int]', declared using local type 'main()::<lambda()>', is used but never defined [-fpermissive]|
||=== Build failed: 10 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|

0 个答案:

没有答案