0_0_23191732_8546.cpp:9:6: error: 'mutex' in namespace 'std' does not name a type
std::mutex mtx;
^
0_0_23191732_8546.cpp: In function 'void print_thread_id(int)':
0_0_23191732_8546.cpp:19:25: error: 'mutex' is not a member of 'std'
std::lock_guard<std::mutex> lck (mtx);//对mtx上锁,保证在析构时解锁
^
0_0_23191732_8546.cpp:19:25: error: 'mutex' is not a member of 'std'
0_0_23191732_8546.cpp:19:35: error: template argument 1 is invalid
std::lock_guard<std::mutex> lck (mtx);//对mtx上锁,保证在析构时解锁
^
0_0_23191732_8546.cpp:19:41: error: invalid type in declaration before '(' token
std::lock_guard<std::mutex> lck (mtx);//对mtx上锁,保证在析构时解锁
^
0_0_23191732_8546.cpp:19:42: error: 'mtx' was not declared in this scope
std::lock_guard<std::mutex> lck (mtx);//对mtx上锁,保证在析构时解锁
^
0_0_23191732_8546.cpp: In function 'int main()':
0_0_23191732_8546.cpp:29:5: error: 'thread' is not a member of 'std'
std::thread threads[10];
^
0_0_23191732_8546.cpp:32:9: error: 'threads' was not declared in this scope
threads[i] = std::thread(print_thread_id,i+1);
^
0_0_23191732_8546.cpp:32:22: error: 'thread' is not a member of 'std'
threads[i] = std::thread(print_thread_id,i+1);
^
0_0_23191732_8546.cpp:34:21: error: 'threads' was not declared in this scope
for (auto& th : threads) th.join();
^
|