使用 C++ 多线程库 <thread> 给出错误“thread”不是“std”的成员

问题描述 投票:0回答:0

我知道这是一个重复的问题,但我读到的答案都没有解决这个问题。因此,我再次发布问题。 我写了这个非常简单的程序

#include<iostream>
#include<thread>

using namespace std;


void func1(char ch){
 for(int i=0; i<100; i++){
    cout<<ch;
 }
}
void func2(char ch){
 for(int i=0; i<100; i++){
    cout<<ch;
 }
}

int main(){
 std::thread worker1(func1, 'a');
 std::thread worker2(func2, 'b');
getchar();
return 0;
}

当使用 (MinGW.org GCC-6.3.0-1) 6.3.0(C++ 14) 编译时,上面的代码给我错误,因为 thread' 不是 'std' 的成员。但是,我可以在位置 C:\MinGW\lib\gcc\mingw32 .3.0\includ 处转到线程的定义

c++ multithreading
© www.soinside.com 2019 - 2024. All rights reserved.