I have just installed CodeBlocks 16.01 on Windows 7 and set it up to use C++ 11 support as described in the former answer here. I then try to run the sample code given here and get the following error messages when I try to compile.
||=== 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)) ===|
EDIT:
The build log is as follows.
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
The output is
||=== 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)) ===|