使用mingw g++ 9.2.0我有一个错误:' mutex'不是STD;

发布于 2025-01-22 13:52:21 字数 852 浏览 1 评论 0原文

我更新了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文