0

I am a newbie to c++. Currently I am learning how to use thread. However, I cannot build and run the program correctly using thread. The system keep giving me warning "'thread' was not declared in this scope". I am using Eclipse OXYGEN and MinGW with Windows 7. I have searched for solution for an entire day. I tried to select the dialect of GCC C++ Compiler as ISO C++11 and added "-std=c++0x" for the editor's discovery. I also tried to add pthread in the library. And I even reinstalled all the stuff, but neither of these help.

Below is the code:

#include <string>
#include <iostream>
#include <thread>
using namespace std;
void task1(string msg){
    cout << "task1 says: " << msg;
}
int main()
{
    thread t1(task1, "Hello");
    t1.join();
    return 0;
}

And the errors are:

..\main.cpp:10:5: error: 'thread' was not declared in this scope

..\main.cpp:11:5: error: 't1' was not declared in this scope

Any suggestion?Thanks a lot.

taeioum
  • 1
  • 3

0 Answers0