Project

General

Profile

Actions

Bug #21128

closed

dir.c defines O_CLOEXEC before it is defined by the system.

Added by collinfunk (Collin Funk) 12 days ago. Updated 7 days ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:120940]

Description

Building from master commit hash bfcf36fe2243d34a01b5707754be9164849150c9 on GNU/Linux, I see:

compiling dir.c
In file included from /usr/include/bits/fcntl.h:61,
                 from /usr/include/fcntl.h:35,
                 from dir.c:39:
/usr/include/bits/fcntl-linux.h:144:10: warning: "O_CLOEXEC" redefined
  144 | # define O_CLOEXEC      __O_CLOEXEC     /* Set close_on_exec.  */
      |          ^~~~~~~~~
dir.c:26:11: note: this is the location of the previous definition
   26 | #  define O_CLOEXEC 0
      |           ^~~~~~~~~

This is because the file includes unistd.h before falling back to 0 for O_CLOEXEC. But glibc requires inclusion of fcntl.h for O_CLOEXEC. Since that file is included after, it is redefined.

The C standard leaves the behavior of redefining a variable undefined and it is a simple fix, so I will create a pull request.

Actions

Also available in: Atom PDF

Like0
Like0Like0