根据我的观察,MinGW使用MSVCRT用于C,而libstdC++用于C++。MinGW如何实现C++库支持?
如果是这样,他们怎么能一起工作?而且,为什么不统一的C和C++的支持,无论MSVCRT + MSVCPRT或油嘴 + 的libstdC++。
我觉得MSVCRT和mixin之间libstdC++听起来很可怕。那么为什么MinGW仍然选择这个?
链接:
- C99 | MinGW
- MinGW | MinGW
- CRT Library Features
- Description of the default C and C++ libraries that a program will link with when built by using Visual C++
下面是我的观察,如果你能跳过它回答问题。
为了编译为本地Windows代码(仅使用Win32 API的),
MinGW的使用MSVCRT作为底层C运行库(提供的Win32 API),
和为了连接从头WIRTE一个桥接层标准C调用和Win32 API调用。
我检查MinGW中的C头文件,例如stdio.h
,它有这样的横幅。
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
而且里面的文件,你会发现很多的_CRTIMP
,这实际上意味着它会转换成Win32 API调用。
但是对于C++部分来说,它是相当有线的。
MinGW似乎使用libstdC++来实现C++支持。
我检查C++头文件,如iostream
,它有这样的
// Standard iostream objects -*- C++ -*-
// Copyright (C) 1997-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
当然没有更多_CRTIMP
或任何MS风格符号的一面旗帜。
因此,MinGW已经使基于MSVCRT的libstdC++作品!
由于C库充满了系统调用包装,并且这些系统调用依赖于Linux/Hurd。从另一方面来说,C++库几乎是用户空间的东西(支持),并且可以在任何合理的C库之上生存 –
@SeverinPappadeux你提醒我了!我甚至忘记了这样一个基本事实。 – Eugene
gcc不太可能与'msvcprt.dll'兼容。 –