C 标准库中包含什么?

What is included in C Standard library?

我将从 The GNU C Library 文档中举一个例子:

13.1 Opening and Closing Files

This section describes the primitives for opening and closing files using file descriptors. The open and creat functions are declared in the header file fcntl.h, while close is declared in unistd.h.

我的问题是:

unistd.hfcntl.h可以算作标准C吗?据我所知,他们应该是Posix standard的一部分?

我们可以说 C 标准库 = Posix 函数 + C API 吗?我很困惑,因为 Wikipedia page for C Standard Library 不包含 unistd.h 但 GNU C 库文档包含它?

据我所知,在C11标准中,没有unistd.hfcntl.h。因此,严格来说,它们不属于 C 标准。

说到实现部分,GNU C libraryglibc)就是其中之一。来自维基页面

glibc provides the functionality required by the Single UNIX Specification, POSIX (1c, 1d, and 1j) and some of the functionality required by ISO C11, ISO C99, Berkeley Unix (BSD) interfaces, the System V Interface Definition (SVID) and the X/Open Portability Guide (XPG), Issue 4.2, with all extensions common to XSI (X/Open System Interface) compliant systems along with all X/Open UNIX extensions.

In addition, glibc also provides extensions that have been deemed useful or necessary while developing GNU.

因此,作为 POSIX 标准的一部分,它们在 glibc 中可用。

参考:查看C11标准draft version here.

不,unistd.hfcntl.h等都不是标准C。

通常,标准 C 不包含处理低级文件操作的函数。例如,fopenfreadfwrite 是标准 C 库的一部分。虽然 POSIX openreadwrite 函数不是标准 C.