I write a c program which includes fcntl.h
file. I search the file and get results as follow:
[xunyl@localhost csapp]$ find /usr/include/ -name "fcntl.h"
/usr/include/asm/fcntl.h
/usr/include/asm-generic/fcntl.h
/usr/include/linux/fcntl.h
/usr/include/sys/fcntl.h
/usr/include/bits/fcntl.h
/usr/include/fcntl.h
[xunyl@localhost csapp]$ grep -rn "O_RDONLY" /usr/include/
/usr/include/asm-generic/fcntl.h:19:#define O_RDONLY 00000000
/usr/include/linux/cdrom.h:32: * - drive = open("/dev/cdrom", O_RDONLY);
/usr/include/linux/cdrom.h:33: * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
...
I find gcc calls /usr/include/asm-generic/fcntl.h
actually when I put #include <fcntl.h>
in program. I just wonder how gcc determines which "fcntl.h" should be called. Is there any call order or precedence ?
Description. The /usr/include/fcntl. h file defines the values that can be specified for the Command and Argument parameters of the fcntl subroutine and for the Oflag parameter of the open subroutine. The file-status flags of an open file are described in the following information. Flag Values for open Subroutine.
h is the header in the C POSIX library for the C programming language that contains constructs that refer to file control, e.g. opening a file, retrieving and changing the permissions of file, locking a file for edit, etc.
If a shared or exclusive lock cannot be set, fcntl() will return immediately with a return value of -1. This command is the same as F_SETLK except that if a shared or exclusive lock is blocked by other locks, the thread will wait until the request can be satisfied.
One includes another which includes the next until the one with the definition is included.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With