1

I'm trying to get size of pipe:

printf("pipe 0 size: %d bytes\npipe 1 size: %d bytes\n", fcntl(fd[0], F_GETPIPE_SZ), fcntl(fd[1], F_GETPIPE_SZ));

Used headers (half of them used by another parts of code):

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/wait.h>

When I'm trying to compile, gcc fails with this error:

‘F_GETPIPE_SZ’ undeclared (first use in this function)

kernel version - 5.4.0-88-generic

libc6-dev version - 2.31-0ubuntu9.2

gcc version - 4:9.3.0-1ubuntu2

zexed640
  • 167
  • 1
  • 6

1 Answers1

2

Since this macro is not part of POSIX, you must define the _GNU_SOURCE feature test macro before including <fcntl.h>.

This is stated in the fcntl(2) man page, in the "Conforming To" section.

See What does "#define _GNU_SOURCE" imply?

Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82