I have an application that uses the mmap system call, I was having an issue getting it to compile for hours looking as to why I was getting MAP_ANON and MAP_ANONYMOUS were undeclared, I had a smaller section of code that I used and I saw I could compile it just fine so I tried just a basic compile and that worked, I saw that it fails when you add -std=c99. Is there a specific reason that MAP_ANON and MAP_ANONYMOUS are not valid in the C99 standard? I know that they aren't defined by POSIX but are defined by BSD SOURCE so I just want to know why that is.
You probably want -std=gnu99
instead of -std=c99
. C99 mode explicitly disables (most) GNU extensions.
I wrote a simple test:
#include <sys/mman.h>
int a = MAP_ANONYMOUS;
In C99 mode, it doesn't find the value:
$ gcc -std=c99 -c d.c
d.c:3:9: error: ‘MAP_ANONYMOUS’ undeclared here (not in a function)
Whereas in Gnu99 mode, it does:
$ gcc -std=gnu99 -c d.c
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