什么是C/C++的标准库?

本文介绍了C/C++标准库的作用、制定过程以及在不同操作系统中的实现,包括C标准库(如glibc)、C++标准库(如libstdc++、libc++)以及在Windows、Android等平台上的实现。标准库提供了诸如输入/输出、内存管理和数学计算等功能,其具体实现依赖于操作系统提供的系统调用。在资源有限的系统或嵌入式开发中,可能会选择轻量级的库实现。

简要介绍编写C/C ++应用程序的领域,标准库的作用以及它是如何在各种操作系统中实现的。
 做为一个从事C/C++多年的程序员,从一开始就让我感到疑惑的是其内部结构:我所使用的内核函数和类从何而来? 谁发明了它们? 他们是打包在我系统中的某个地方吗? 是否存在一份官方的C ++手册?
  在本文中,我将通过从C和C ++语言的本质到实际实现来尝试回答这些问题。


 C和C++是如何制订的
  当我们谈论C和C++时,实际上是指一组定义(程序)语言应该做些什么,如何表现,应该提供哪些功能的规则。C/C++的编译器为了处理C/C++编写的源代码必须跟随着这些规则,并生成二进制应用程序。听起来非常接近于HTML:浏览器遵循着一组指令,所以它们可以以明确的方式来渲染网页。
与HTML一样,C和C++的规则都是理论上的。国际标准化组织(ISO)的一大群人每年都会聚集几次来讨论和定义语言规则。没错,C和C++是标准化的东西。他们最终都会得到一本官方的叫标准的书,你可以从他们的网站中购买。随着语言的发展新的papers(指官方的叫标准的书)会被发布,每一次都定义一个新的标准。这就是为什么我们会有不同的C和C++版本的原因:C99, C11, C++03, C++11, C++14等等,数字与出版/发布年份相符。
  这些标准都市非常详细和有技术新的文档:我不会把它们当作手册。通常会分为两部分:
  1.C/C++的功能和特性;
  2.C/C++的API--开发人员可以用于他们的C/C++程序的一个类、函数和宏的集合。它也被称为标准库。
  例如,这里有个来自于C标准库第一部分的摘选,它定义了main函数的结构:

 

1.main的定义,程序启动时调用的函数。

关于main定义图暂时没能发送出来,对于

此图大家想

C++ Standard Library Quick Reference by Peter Van Weert, Marc Gregoire 2016 | ISBN: 1484218752 | English | 206 pages PDF+EPUB This quick reference is a condensed reference guide to the essential data structures, algorithms, and functions provided by the C++ Standard Library. More specifically, this is a compact collection of essential classes and functions, used by C++ programmers on a daily basis. The C++ Standard Library Quick Reference features core classes for strings, I/O streams, and various generic containers, as well as a comprehensive set of algorithms to manipulate them. In recent years, the C++11 and C++14 standards have added even more efficient container classes, a new powerful regular expression library, and a portable multithreading library featuring threads, mutexes, condition variables, and atomic variables. Needless to say, it is hard to know and remember all the possibilities, details, and intricacies of this vast and growing library. This handy reference guide is therefore indispensable to any C++ programmer. It offers a condensed, well-structured summary of all essential aspects of the C++ Standard Library, including all aforementioned functionality. No page-long, repetitive examples or obscure, rarely used features. Instead, everything you need to know and watch out for in practice is outlined in a compact, to-the-point style, interspersed with well-chosen, clarifying examples. The book does not explain the C++ language or syntax, but is accessible to anyone with basic C++ knowledge. Even the most experienced C++ programmer though will learn a thing or two from it and find it a useful memory-aid. What You Will Learn • The essentials that the C++ Standard Library has to offer • How to use containers to efficiently store and retrieve your data • How to use algorithms to inspect and manipulate your data • How lambda expressions allow for elegant use of algorithms • What the standard string class provides and how to use it • What functionality the library provides for file and stream-based I/O • What smart pointers are and how to use them to prevent memory leaks • How to write safe and efficient multi-threaded code using the C++11 threading libraries
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值