未知类型名称'caddr_t'错误

时间:2011-11-11 03:22:20

标签: c linux variables

我正在尝试使用

设置“共享”内存位置
caddr_t mmap_ptr;

但是我收到了错误。有帮助吗?谢谢!

另外

mmap_ptr = mmap((caddr_t) 0,   /* Memory Location, 0 lets O/S choose */
    MAX_BUFFER_SIZE,/* How many bytes to mmap */
    PROT_READ | PROT_WRITE, /* Read and write permissions */
    MAP_SHARED,    /* Accessible by another process */
    fid,           /* which file is associated with mmap */
    (off_t) 0);    /* Offset in page frame */

1 个答案:

答案 0 :(得分:2)

caddr_t是一个BSD主义,而且是旧的。在Linux(和POSIX)下,mmap返回一个void指针。

#include <sys/mman.h>
void *mmap (void *addr,
            size_t length,
            int prot,
            int flags,
            int fd,
            off_t offset);
int munmap (void *addr,
            size_t length);