-
C標準函數庫
鎖定
C標準函數庫(C Standard library)是所有符合標準的頭文件(head file)的集合,以及常用的函數庫實現程序,例如I/O 輸入輸出和字符串控制。不像 COBOL、Fortran 和 PL/I等編程語言,在 C 語言的工作任務裏不會包含嵌入的關鍵字,所以幾乎所有的 C 語言程序都是由標準函數庫的函數來創建的。
- 中文名
- C標準函數庫
- 類 別
- C語言
- 庫類型
- 頭文件
- 源 自
- C99
C標準函數庫設計
每一個函數的名稱與特性會被寫成一個電腦文件,這個文件就稱為頭文件,但是實際的函數實現是被分存到函數庫文件裏。頭文件的命名和領域是很常見的,但是函數庫的組織架構也會因為不同的編譯器而有所不同。標準函數庫通常會隨附在編譯器上。因為 C 編譯器常會提供一些額外的非 ANSI C 函數功能,所以某個隨附在特定編譯器上的標準函數庫,對其他不同的編譯器來説,是不兼容的。
C標準函數庫設計質量
大多 C 標準函數庫在設計上做得相當不錯。有些少部分的,會為了商業優勢和利益,會把某些舊函數視同錯誤或提出警告。字符串輸入函數 gets()(以及 scanf() 讀取字符串輸入的使用上)是很多緩存溢出的原因,而且大多的程序設計指南會建議避免使用它。另一個較為奇特的函數是 strtok(),它原本是作為早期的詞彙分析用途,但是它非常容易出錯(fragile),而且很難使用。
C標準函數庫歷史沿革
1995年,Normative Addendum 1 (NA1)批准了三個頭文件(iso646.h, wchar.h, and wctype.h)增加到C標準函數庫中。C99標準增加了六個頭文件(complex.h, fenv.h, inttypes.h, stdbool.h, stdint.h, and tgmath.h)。C11標準中又新增了5個頭文件(stdalign.h, stdatomic.h, stdnoreturn.h, threads.h, and uchar.h)。至此,C標準函數庫共29個頭文件
[1]
:
名字 | 源自 | 描述 |
---|---|---|
包含斷言宏,被用來在程序的調試版本中幫助檢測邏輯錯誤以及其他類型的bug。 | ||
C99 | 一組操作複數的函數。 | |
用來測試由庫函數報的錯誤代碼。 | ||
C99 | 定義了一組用來控制浮點數環境的函數。 | |
Defines macro constants specifying the implementation-specific properties of the 浮點數 library. | ||
C99 | Defines exact width integer types. | |
NA1 | Defines several macros that are equivalent to some of the operators in C. For programming in ISO 646 variant character sets. | |
Defines macro constants specifying the implementation-specific properties of theinteger types. | ||
定義C語言本地化函數. | ||
定義C語言數學函數。 | ||
定義了宏setjmp和longjmp,在非局部跳轉的時候使用。 | ||
定義C語言信號處理函數。 | ||
C11 | For querying and specifying the data structure alignment of objects. | |
For accessing a varying number of arguments passed to functions. | ||
C11 | For atomic operations on data shared between threads. | |
C99 | Defines a boolean data type. | |
Defines several useful types and macros. | ||
C99 | Defines exact width integer types. | |
Defines core input and output functions | ||
Defines numeric conversion functions, pseudo-random numbers generation functions, dynamicmemory allocation, process control functions | ||
C11 | For specifying non-returning functions. | |
定義C語言字符串處理函數 | ||
C99 | Defines type-generic mathematical functions. | |
C11 | Defines functions for managing multiple threads as well as mutexes and condition variables. | |
<time.h> | Defines date and time handling functions | |
C11 | Types and functions for manipulating Unicode characters. | |
NA1 | Defines wide string handling functions. | |
NA1 | Defines set of functions used to classify wide characters by their types or to convert between upper and lower case |
- 參考資料
-
- 1. ISO/IEC 9899:1999 Programming languages -- C .International Organization for Standardization.2011-12-08[引用日期2017-03-16]