Falcata
Falcata

Reputation: 707

unknown type name ‘caddr_t’ error

I am trying to setup a 'shared' memory location using

caddr_t mmap_ptr;

But am getting an error. Any help? Thanks!

Also

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 */

Upvotes: 3

Views: 5237

Answers (1)

paxdiablo
paxdiablo

Reputation: 881623

caddr_t is a BSD-ism, and an old one at that. Under Linux (and POSIX), mmap returns a void pointer.

#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);

Upvotes: 2

Related Questions