Home  >  Article  >  Backend Development  >  Does MinGW-w64 with the Win32 threading model support std::thread natively?

Does MinGW-w64 with the Win32 threading model support std::thread natively?

DDD
DDDOriginal
2024-10-31 23:46:29304browse

Does MinGW-w64 with the Win32 threading model support std::thread natively?

Does MinGW-w64 natively support std::thread with Win32 threading model?

When using the MinGW-w64 toolchain, selecting the Win32 threading model may raise concerns about the availability of C 11 thread support.

Initially, it was believed that std::thread could be used regardless of the threading model based on previous statements. However, that assumption proved incorrect.

Despite invoking g with -std=c 11, std::thread remains unsupported. The options to reconcile this discrepancy are:

  • Misinformation: The initial assumption that C 11 threads would work with the Win32 threading model was incorrect.
  • Misunderstanding: Despite inquiries, it's still unclear whether std::thread support exists in this scenario.
  • Support but with unexpected implementation: std::thread may be supported but not in an intuitive manner.

However, the "out of the box" qualification in the question excludes third-party options like mingw-std-threads.

Native std::thread Support

As of May 2016, native std::thread support in MinGW-w64 with the Win32 threading model is achieved by installing the mingw-std-threads headers.

This is because MinGW-w64 lacks native thread support like other GCC installations that implement threading via gthreads or pthreads. MinGW-w64 also lacks a glibc port but uses MSVC runtime and its own code to fill in missing components.

Recent versions of MinGW-w64 include a Win32 port of pthreads ("winpthreads"), which explains why selecting the "pthread" model during installation enables threads.

The above is the detailed content of Does MinGW-w64 with the Win32 threading model support std::thread natively?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn