1

Possible Duplicate:
C++11 threading on Windows

The title pretty much describes it, I'm trying to use the following code:

#include <thread>
#include <iostream>

using namespace std;

void task_1(){
    cout << "Thread 1" << endl;
}

int main(){
    thread task(task_1);
    task.join();
    return 1;
}

but it gives a compiler error

D:\dev\cpp\trash\thread.cpp|11|error: 'thread' was not declared this scope|

I'm using Code:Blocks 10.05 with GNU GCC compiler, with option -std=c++0x

Code:Blocks was just recently downloaded so I would guess that everything should be up to date.

Community
  • 1
  • 1
Vultour
  • 373
  • 4
  • 15

2 Answers2

2

The error you show is a compiler error, so linker options will not have any effect. You need to ensure that you're correctly configuring the compiler to support C++11 features such as std::thread. Using the compiler (as opposed to linker) option -std=c++0x or -std=c++11 may be all that's necessary.

bames53
  • 79,748
  • 13
  • 162
  • 229
0

You should be aware that C++11 support is still very much experimental in GCC. Support is oncoming but some regressions still exist. See http://gcc.gnu.org/

yungtrizzle
  • 51
  • 2
  • 5