As per the man page, I have defined _GNU_SOURCE
before the inclusion of <fcntl.h
:
#include <stdio.h>
#define _GNU_SOURCE /* For Linux's fallocate(). */
#define HAVE_FALLOCATE 1
#include <fcntl.h>
int main(void)
{
printf("%dn", FALLOC_FL_KEEP_SIZE);
}
Yet this code fails to compile with:
error: `FALLOC_FL_KEEP_SIZE` undeclared (first use in this function)
I compiled the code with:
gcc-13 -std=gnu2x c.c
Some stats about the environment:
OS: Linux Mint 21.2 x86_64
Kernel: 5.15.0-112-generic
GLIBC Version: GNU C Library (Ubuntu GLIBC 2.35-0ubuntu3.8) stable release 2.35
Compiler: gcc version 13.1.0 (Ubuntu 13.1.0-8ubuntu1~22.04)
Running grep -r FALLOC_FL_KEEP_SIZE /usr/include
returned:
/usr/include/linux/falloc.h:#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
/usr/include/linux/falloc.h: * with fallocate. Flag FALLOC_FL_KEEP_SIZE should cause the inode