fork(3) download
  1. #include <iostream>
  2. #include <thread>
  3.  
  4. void foo() {
  5.  
  6. for (int i = 0; i < 20; ++i) {
  7. std::cout << "foo" << std::endl;
  8. }
  9. }
  10.  
  11.  
  12. int main(int argc, char** argv) {
  13.  
  14. std::thread first(foo);
  15. for (int i = 0; i < 20; ++i) {
  16. std::cout << "main" << std::endl;
  17. }
  18. first.join();
  19. return 0;
  20. }
Compilation error #stdin compilation error #stdout 0s 3340KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/4.8/thread:35:0,
                 from prog.cpp:2:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:14:5: error: ‘thread’ is not a member of ‘std’
     std::thread first(foo);
     ^
prog.cpp:14:17: error: expected ‘;’ before ‘first’
     std::thread first(foo);
                 ^
prog.cpp:18:5: error: ‘first’ was not declared in this scope
     first.join();
     ^
stdout
Standard output is empty