I am trying to make a basic multithreaded application in c++ using the g++ compiler (mingw32 9.2.0). The code I am using:
#include <iostream>
#include <thread>
int N = 0;
void dostuff() {
N++;
}
int main() {
std::thread t(dostuff);
std::cout << N;
}
However, this simple code fails to compile, with g++ saying 'thread' is not a member of 'std'
(compiling with g++ -pthread -std=c++0x test.cpp -o test
, and also hilariously saying did you forget to '#include <thread>'
, and showing corrected code with #include <thread>
right below where I put it! You can see that here.
I am at a complete loss as to why this doesn't work - I have searched around, using this article and also this one, to no avail.