loukwn
loukwn

Reputation: 174

Weird thread issue

Alright im compiling the following simple chunk of code (found on cplusplus.com) on CodeBlocks IDE 12.11 with MinGW (downloaded separately and latest version too as of today). The thing is that it shows the following errors upon compilation:

12: error: 'thread' was not declared in this scope

12: error: expected ';' before 't1'

13: error: 't1' was not declared in this scope

#include <iostream>
#include <thread>

using namespace std;

void hello(void){
    cout << "hey there!" << endl;
}

int main()
{
    thread t1(hello);
    t1.join();
    return 0;
}

Are threads not supported by GCC completely?Do i need to add flags to my compiler, and how do i do it on a codeblocks project? thanks in advance

Upvotes: 0

Views: 112

Answers (1)

prajmus
prajmus

Reputation: 3271

Add --std=c++11 -pthread to your Compiler Flags

Upvotes: 1

Related Questions