0.说明

    首先要说明,不同的平台对STL的实现存在细节上的不同,但他们都遵循者一个共同的标准,所以说今天给出
STL在Windows下和在Linux下各自的实现源码.

1.VC

VC版本可以在VS中的VC中看到,我这里给出的版本是VS2015中的VC的目录.VC的分布相对于G++/GCC还是比较清晰的.

VS中的VC

头文件:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
STL源码:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\stl

2.G++/GCC

1.老师说
侯捷老师强烈推荐2.9.1版本源码阅读,侯老师也会说4.9的版本也会讲解,4.9中会有重大不同.
Dev-Cpp_5.11_TDM-GCC_4.9.2_Setup.exe是侯老师推荐的编译器,其内嵌的版本就是GNU4.9.2.
GNUC的STL源码就可以在
D:\002-软件包安装目录\011-VC4-9-2\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits
D:\002-软件包安装目录\011-VC4-9-2\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\ext(ext表示extension)
这两个目录中找到,这两个目录是安装Dev-Cpp_5.11_TDM-GCC_4.9.2_Setup.exe的时候得到的.



2.其他方法看GNU中GCC中G++中的STL
http://ftp.gnu/pub/gnu/gcc/是可以下载到这些G++(在2版的后续版本中已经不单独存在)和GCC编译器的各个版本的地方,
此网站还提供其他很多资源.
如:我们下载
http://ftp.gnu/pub/gnu/gcc/gcc-4.9.2/gcc-4.9.2.tar.gz到我们的电脑上,解压之后,可以看到
我们的STL的源码就在:
D:\005-代码\001-开源项目源码\010-编译器\gcc-4.9.2.tar\gcc-4.9.2\libstdc++-v3\src中(这个是我的电脑里面的绝对路径,
主要找压缩包里面的"libstdc++-v3\src"就好了).


3.G++官方说明
从http://ftp.gnu/pub/gnu/g++.README中可以看到:
G++ is no longer a separate distribution. Version 2 of G++ is an integral part of GCC. You should get the 
gcc-2.n.tar.gz sources (where n is the highest numbered archive) in the gcc/ directory. C++ users will almost
certainly need to retrieve the libstdc++-2.n.tar.gz distribution as well, 
since that's where all the  standard C++ stream classes (and header files like iostream.h) live. 
翻译:G++不再是一个单独的分支.第二版的G++是GCC的一个有机组成部分.如果你想要看G++的相关内容,你应该去 gcc-2.n.tar.gz
这个包中去寻找,这里的n是gcc目录下的最大的归档数字(我觉得应该是http://ftp.gnu/pub/gnu/gcc/gcc-2.95/这个目录下的
G++编译器).
C++用户大部分也肯定会追溯之前的版本(那倒未必),因为那些版本是所有标准C++流式类(比如说像iostream这样的头文件)的发源地.

4.看看你的linux机器的编译器版本
比如说我的一台虚拟机上是这样的:
[muten@localhost ~]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-9/root/usr --mandir=/opt/rh/devtoolset-9/root/usr/share/man --infodir=/opt/rh/devtoolset-9/root/usr/share/info --with-bugurl=http://bugzilla.redhat/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-9.3.1-20200408/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC) 


5.啊啊啊,GCC在今年7月都已经发到10.2.0版本了,我还是个菜鸟.

 

更多推荐

【C++标准库-体系结构与内核分析】STL源码到底在哪里可以看到?