11

I wanted to download the latest available version of gcc 4.7.2 compiler for Windows. When I got to this page where I was supposed to see a download link, I confronted with two categories:

  1. threads-posix
  2. threads-win32

What's the difference between these two? Are they thread implementations only? I mean are they only different in how they are implemented and thus the ending result (classes, how to use them, etc) remains the same? Or do they impose a specific coding style?

halfer
  • 18,701
  • 13
  • 79
  • 158
Rika
  • 19,296
  • 28
  • 91
  • 182

1 Answers1

19

So, the link you provided leads to builds of the standalone gcc 4.7.2 for windows, a.k.a mingw64. In order to build this compiler, a set of scripts are used, which help define the options of compilations. The scripts are simply called MinGW-builds, and can be found in different places:

The scripts have an option which specify which thread model is to be used for the std::threads part of the C++11 standard (this is allowed for MinGW thanks to an experimental patch applied on that version of GCC). In one case, the win32 thread API is used, and in the other case it's the posix API which is used.

Note that Windows doesn't support all the POSIX API out of the box, so some external emulation library needs to be used (winpthreads).

The GCC source configure script has an option to specify that API (--enable-threads=), and that's what is used in the build scripts.

In short, for this version of mingw, the threads-posix release will use the posix API and allow the use of std::thread, and the threads-win32 will use the win32 API, and disable the std::thread part of the standard.

didierc
  • 14,109
  • 3
  • 30
  • 51
  • 2
    For completeness (because it only works for 5.3.0 and up), https://github.com/meganz/mingw-std-threads makes it possible to use std::thread with the win32 threading model. – Jerry Jeremiah Mar 20 '16 at 22:55