C语言标准库中包括什么?[英] What is included in C Standard library?

本文是小编为大家收集整理的关于C语言标准库中包括什么?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我将举一个示例,来自 nonnofollow "> GNU C库文档:

13.1打开和关闭文件

本节描述了用于打开和关闭文件的原始内容 使用文件描述符.开放和创建功能在 标题文件fcntl.h,而关闭在Unistd.h.

中声明

我的问题是:

可以将unistd.h和fcntl.h视为标准C?据我所知,它们应该成为 posix standard ?

我们可以说C标准库= POSIX函数 + C API吗?我很困惑,因为 wikipedia for C Standard Library 不包括unistd.h文档包括吗?

据我所知,

推荐答案

在C11标准中,没有unistd.h和fcntl.h.因此,严格来说,它们不是C标准的一部分.

当涉及实施部分时, gnu c库(glibc)是其中之一.从Wiki页面

glibc提供了单个Unix规范,POSIX(1C,1D和1J)所需的功能,以及ISO C11,ISO C99,Berkeley Unix(BSD)接口所需的某些功能(SVID)和X/OPEN可移植性指南(XPG),第4.2期,XSI(X/Open System接口)符合所有XSI(X/Open System接口)的所有扩展系统以及所有X/OPEN UNIX扩展.

此外,glibc还提供了在开发GNU时被认为有用或必要的扩展.

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

参考:检查C11标准.

其他推荐答案

no,unistd.h,fcntl.h等,不是标准c.

通常,标准C不包括处理低级别文件操作的功能.例如,fopen,fread和fwrite是标准C库的一部分.而posix open,read,write函数不是标准c.

本文地址:https://www.itbaoku.cn/post/2335223.html

问题描述

I will give an example from The GNU C Library documentation:

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.

My question is:

Can unistd.h and fcntl.h be considered as Standard C? As far as I know, they should be part of the Posix standard?

Can we say C Standard Library = Posix functions + C API? I am confused because Wikipedia page for C Standard Library does not include unistd.h but the GNU C Library documentation includes it?

推荐答案

As far as I can see, in C11 standard, there is no unistd.h and fcntl.h. So, strictly speaking, they are not part of the C standard.

When it comes to the implementation part, the GNU C library (glibc) is one of them. From the wiki page

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.

So, as a part of the POSIX standard, they are available in glibc.

Reference: Check the C11 standard draft version here.

其他推荐答案

No, unistd.h, fcntl.h, etc, are not standard C.

In general, standard C doesn't include functions that deal with low level file manipulation. For example, fopen, fread, and fwrite are part of standard C library. While POSIX open, read, write functions are not standard C.