从哪里获得 C++ 标准库的源代码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2004212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 21:49:02  来源:igfitidea点击:

Where to get the source code for the C++ standard library?

c++visual-c++

提问by Southsouth

is it possible to get the source code for standard c++ library?

是否可以获取标准 C++ 库的源代码?

回答by Grant Paul

The GNU project is Free and Open Source software, and contains an implementation of the C++ standard library.

GNU 项目是自由开源软件,包含 C++ 标准库的实现。

http://gcc.gnu.org/libstdc++/

http://gcc.gnu.org/libstdc++/

回答by wallyk

If you have Visual Studio Professional, it has source code in

如果你有 Visual Studio Professional,它的源代码在

X:\Microsoft Visual Studio 9.0\VC\crt\src

X:\Microsoft Visual Studio 9.0\VC\crt\src

回答by Potatoswatter

You should already have the sources in your compiler installation. If you are using an IDE with a "jump to include file" command, select any STL header and jump to it. If you are using some kind of UNIX, look in /usr/include/c++. See where that STL header includes other headers and recurse :v) .

您的编译器安装中应该已经有了源代码。如果您使用带有“跳转到包含文件”命令的 IDE,请选择任何 STL 标头并跳转到它。如果您使用的是某种 UNIX,请查看/usr/include/c++. 查看该 STL 标头在哪里包含其他标头和递归 :v) 。

回答by aggsol

libc++is the C++ Standard Library of LLVM.

libc++是 LLVM 的 C++ 标准库。

All of the code in libc++ is dual licensed under the MIT license and the UIUC License (a BSD-like license).

libc++ 中的所有代码都获得了 MIT 许可和 UIUC 许可(类似 BSD 的许可)的双重许可。

  • Correctness as defined by the C++11 standard.
  • Fast execution.
  • Minimal memory use.
  • Fast compile times.
  • ABI compatibility with gcc's libstdc++ for some low-level features such as exception objects, rtti and memory allocation.
  • Extensive unit tests.
  • C++11 标准定义的正确性。
  • 快速执行。
  • 最少的内存使用。
  • 快速编译时间。
  • ABI 与 gcc 的 libstdc++ 兼容,用于一些低级功能,例如异常对象、rtti 和内存分配。
  • 广泛的单元测试。

回答by Hassen Dhia

This is it :

就是这个 :

https://github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3

https://github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3

As a part of gcc source code

作为 gcc 源代码的一部分

https://github.com/gcc-mirror/gcc

https://github.com/gcc-mirror/gcc

that's the std library for c++

这是 C++ 的标准库

i think this is the only answer with the direct one click link

我认为这是直接单击链接的唯一答案

回答by jw_

For Win10x64 with VS2017 default install paths,the source code are here:

对于 VS2017 默认安装路径的 Win10x64,源代码在这里:

part1:VCRuntime,which include code that will change for every version of Visual Studio,it contains function like the CRT entry point "mainCRTStartup",the code are here:

第1部分:VCRuntime,其中包含随Visual Studio不同版本而变化的代码,包含CRT入口点“mainCRTStartup”等功能,代码如下:

C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\VC\Tools\MSVC.16.27023\crt\src

part2:C standard library,which include code that is stable over generations of Visual Studio,like the function fopen,and it also contains stable CRT functions like _initterm,the code are here:

第2部分:C标准库,包括在Visual Studio几代稳定的代码,如fopen函数,还包含稳定的CRT函数如_initterm,代码在这里:

C:\Program Files (x86)\Windows Kits\Source.0.17763.0\ucrt

i.e. this part has been moved to Windows SDK,distributed with Windows instead of Visual Studio.

即这部分已移至 Windows SDK,随 Windows 而不是 Visual Studio 分发。

references:

参考:

https://devblogs.microsoft.com/cppblog/introducing-the-universal-crt/

https://devblogs.microsoft.com/cppblog/introducing-the-universal-crt/

回答by user1234567

In Visual Studio if you interesting in concrete(specific) STL-element implementation (for example, any function), right click on its mention in your code and chose "Go to Definition" in context menu. (Or place cursor on this mention and push "F12")

在 Visual Studio 中,如果您对具体的(特定的)STL 元素实现(例如,任何函数)感兴趣,请右键单击代码中的提及并在上下文菜单中选择“转到定义”。(或将光标置于此提及并按“F12”)

回答by Luca Cappa

Since today 16th September 2019 the Microsoft MSVC's STLis available on GitHub.

自 2019 年 9 月 16 日起,Microsoft MSVC 的 STL可在 GitHub 上获得。

回答by Eugen Constantin Dinca

Don't forget STLPort& the SGIones.

不要忘记STLPortSGI的。