Windows的gcc端口中的thread_posixs和thread_win32有什么区别? [英] What's the difference between thread_posixs and thread_win32 in gcc port of Windows?

查看:455
本文介绍了Windows的gcc端口中的thread_posixs和thread_win32有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想下载 gcc 4.7.2 Windows编译器的最新版本。当我到达此页面在应该看到下载链接的地方,我遇到了两种类别:

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?

推荐答案

因此,您提供的链接将导致建立独立的gcc 4.7.2。对于Windows,又名mingw64。为了构建此编译器,使用了一组脚本,这些脚本有助于定义编译选项。这些脚本简称为MinGW-builds,可以在不同的地方找到:

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:

  • google code
  • github fork

脚本具有一个选项,用于指定将哪种线程模型用于std :: threads部分。 C ++ 11标准(由于在该版本上应用了实验补丁,MinGW才允许使用此标准) GCC)。
在一种情况下,将使用win32线程API,在另一种情况下,将使用posix API。

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.

请注意,Windows不会暂时不支持所有POSIX API,因此需要使用一些外部仿真库(winpthreads)。

GCC源配置脚本具有一个指定该API的选项(--enable-threads =),这就是构建脚本中使用的API。

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

简而言之,对于此版本的mingw, thread-posix版本将使用posix API,并允许使用std :: thread ,而threads-win32将使用win32 API,并禁用该模块的std :: thread部分标准

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.

这篇关于Windows的gcc端口中的thread_posixs和thread_win32有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆