Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F_SETPIPE_SZ undeclared

Tags:

c

linux

fcntl

I have included following headers:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

I have also tried to use

#define _GNU_SOURCE

before #include <unistd.h>, but it also does not help.

I try to use fcntl and pass it F_SETPIPE_SZ as second argument, but I keep getting this error message:

error: ‘F_SETPIPE_SZ’ undeclared (first use in this function)

I actually found out that I don't need this, but I'm just curious why I can't use it.

Thank you.

So here's solution, thanks to Chrono Kitsune: Put

 #define _GNU_SOURCE

before any includes.

like image 958
Marko Avatar asked Aug 20 '14 18:08

Marko


2 Answers

So here's the solution, thanks to Chrono Kitsune:

Put

#define _GNU_SOURCE

before any includes.

You should also pay attention to Chrono Kitsune's other comment.

like image 82
Marko Avatar answered Oct 16 '22 13:10

Marko


F_SETPIPE_SZ/F_GETPIPE_SZ are relatively recent. Older kernels (e.g. 2.6.32 as used in RHEL6) don't have them. If you look in /usr/include/linux/fcntl.h and these constants aren't defined, then this API isn't going to work and you'll have to find some way to bypass it in whatever you're building.

like image 31
user6017522 Avatar answered Oct 16 '22 13:10

user6017522