Reputation: 23854
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?
Upvotes: 3
Views: 3005
Reputation: 134396
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.
Upvotes: 3
Reputation: 122493
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.
Upvotes: 5