根據我的觀察,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'兼容。 –