使用mingw g++ 9.2.0我有一个错误:' mutex'不是STD;
我更新了G ++,因为我的较旧版本没有完全支持std :: Filesystem
,但是现在我根本无法使用Mutexes。示例代码:
#include <mutex>
int main(const int argc, const char** argv)
{
std::mutex test;
return 0;
}
编译以下:
g++ -Wall -pedantic main.cpp -std=c++17 -o main.exe
添加添加。
main.cpp: In function 'int main(int, const char**)':
main.cpp:5:8: error: 'mutex' is not a member of 'std'
5 | std::mutex test;
| ^~~~~
main.cpp:2:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
1 | #include <mutex>
+++ |+#include <mutex>
2 |
错误,请注意如何添加&lt; mutex&gt;
的 org gcc build-2)9.2.0 。我使用MINGW安装管理器安装了MINGW。我是否有可能缺少正确版本的stdlib?
我在MingW目录中打开了mutex
文件,我看不到显然是错误的。
I updated my g++ because my older version didn't fully support std::filesystem
, but now I cannot use mutexes at all. Example code:
#include <mutex>
int main(const int argc, const char** argv)
{
std::mutex test;
return 0;
}
Compiled with:
g++ -Wall -pedantic main.cpp -std=c++17 -o main.exe
The error, note how it suggests adding include for <mutex>
right under the include that is already there:
main.cpp: In function 'int main(int, const char**)':
main.cpp:5:8: error: 'mutex' is not a member of 'std'
5 | std::mutex test;
| ^~~~~
main.cpp:2:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
1 | #include <mutex>
+++ |+#include <mutex>
2 |
The full version of g++ is: g++ (MinGW.org GCC Build-2) 9.2.0
. I installed MinGW using the MinGW installation manager. Is it possible that I am missing the correct version of stdlib?
I opened the mutex
file in the MinGW directory and I see nothing that would be obviously wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论