Reputation: 1219
This is my mman.h
file included from /usr/include/sys/
:
Somehow mmap()
seems to be defined (and can be used with flags 0 and read/write protection), but not MAP_ANON
or MAP_ANONYMOUS
as indicated below:
#include <sys/mman.h>
int a = MAP_ANON; /* compile error */
int b = MAP_ANONYMOUS; /* also compile error */
I'm at a loss of what could be wrong. I'm compiling using this makefile:
EDIT: It turns out the MAP_ANONYMOUS
macro is defined in /usr/include/bits/mman.h
but only if __USE_MISC
is defined...
Any help would be terrific!
Upvotes: 4
Views: 5869
Reputation: 3931
If you're using GCC, a common reason for this to occur is that you're not using a GNU C standard. Try compiling with, e.g., -std=gnu11
, and see if that fixes the problem.
More information about GCC's language standards can be found here.
GCC also provides a very exhaustive list of exactly what extensions they provide here.
Also, as a side note, it's preferrable to use MAP_ANONYMOUS
instead of MAP_ANON
, as the latter is deprecated (according to man mmap
).
Upvotes: 6