如何獲取 C++ 標准庫的源碼


獲取 C++ 標准庫主要有兩種途徑: 從 C++ 編譯器的安裝位置(Your C++ compiler installation location)和直接查看或下載網上開源代碼(Online open source codes). 具體如下:

C++編譯器的安裝位置(Your C++ compiler installation location)

Windows OS

Visual Studio — X:\Microsoft Visual Studio 9.0\VC\crt\src; X:\Program files (x86)\Microsoft Visual Studio 14.0\VC\include\; X:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\crt\src
Note,
1) You even don't have to install Visual Studio to explore Microsoft implementation. Online compilers can help: rextester.com/NRP17506
2) 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")

Linux/Unix

gcc/usr/include/c++/; /usr/lib/gcc/$CTARGET/$VERSION/include/g++-v4/
Note, `locate iostream` is a good solution to find the installation location.
 

網上開源代碼(Online open source codes)

  • libc++

libc++ — the C++ standard library of LLVM project.
libc++ is an implementation of the C++ standard library, targeting C++11, C++14 and above.
http://libcxx.llvm.org/
https://github.com/llvm/llvm-project/tree/master/libcxx/

 

  • gcc

GCC, the GNU Compiler Collection
The GNU project is Free and Open Source software, and contains an implementation of the C++ standard library.
https://github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3
https://github.com/gcc-mirror/gcc

 

  • Apache stdcxx

Apache C++ Standard Library.
The Apache C++ Standard Library project (code name stdcxx, pronounced "standard C++ library", not S-T-D-C-X-X) is a collection of algorithms, containers, iterators, and other fundamental components of every piece of software, implemented as C++ classes, templates, and functions essential for writing C++ programs.
http://stdcxx.apache.org/
http://svn.apache.org/repos/asf/stdcxx/

 

  • STLport

Multiplatform C++ Standard Library (STL implementation). Many compilers and operational environments supported. Standard (ISO/IEC 14882) compliance. Maximum efficiency. Exception and thread safety. Debug mode.
http://www.stlport.org/
https://sourceforge.net/projects/stlport/

  

  • SGI STL

SGI(Silicon Graphics Computer Systems, Inc.) implement STL(C++ Standard Libirary).
https://github.com/karottc/sgi-stl

 

  • MSVC STL

Microsoft's C++ Standard Library
MSVC's implementation of the C++ Standard Library. https://github.com/microsoft/STL

 

參考資料

[1] https://stackoverflow.com/questions/2004212/where-to-get-the-source-code-for-the-c-standard-library 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM