MAP_ANONYMOUS with C99 standard

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>


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

Need Your Help

What are differences between std, tr1 and boost (as namespaces and/or libraries)?

c++ c++11 boost tr1

I initially thought they're all the same, but it turned out to be wrong. So can anyone briefly explain the differences between these three? For example:

Sorting ArrayList with Lambda in Java 8

java lambda functional-programming java-8

Could somebody show me a quick example how to sort an ArrayList alphabetically in Java 8 using the new lambda syntax.