MAP_ANONYMOUS with C99 standard

后端 未结 1 1291
别那么骄傲
别那么骄傲 2021-02-12 12:19

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 undec

相关标签:
1条回答
  • 2021-02-12 12:54

    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
    
    0 讨论(0)
提交回复
热议问题