栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

关于 GNU 的 STL 版本更替

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

关于 GNU 的 STL 版本更替

最近在看侯捷老师的《STL 源码剖析》,当读到 STL 的实现版本时,其中提到:

SGI 版本被 GCC 采用。你可以在 GCC 的 include 目录中(相对于 cygwin 的安装目录,其相对路径为 .libgccx86_64-pc-cygwin10includec++,我们下面的目录都以此目录为根目录)找到所有 STL 文件。

但是我在自己的 MinGW 上找到的 STL 并不是 SGI 的实现。起初我以为是系统的原因,所以我安装了 Cygwin,又去 Linux 上用 yum 安装了 gcc 和 g++ ,并查看了它们的 libstdc++,发现还不是 SGI 的实现(比如不存在 stl_alloc.h 头文件)。后来我在网上的某个网友的分享里发现了下面这句话:

GNU STL
这是 GCC 自带的 STL 实现,包含在 libstdc++ 这个库里面,写 C++ 一旦用到库函数是基本会链接这个库。GNU STL 是在 SGI STL 基础上开发的,所以 SGI STL 我就不再单独列出了。

并且之前查看的不是 SGI 实现的源码开头都有这段话(只有第一行的时间不同):

// Copyright © 2001-2021 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.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// http://www.gnu.org/licenses/.

考虑到作者当年的编译环境,于是我觉得可能是 Free Software Foundation 公司在 2001-2021 这段时间都不再直接使用 SGI STL,而是对其进行了整合。

在 GNU 的 API 分享中查找以往发布的 libstdc++,并选择一个在2001年前的下载下来。

此时我们下载并查看 STL 的相关文件,终于发现了 SGI STL 的相关头文件:


留待以后更新

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/954741.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号