Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unknown type name ‘caddr_t’ error

Tags:

c

variables

linux

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 */
like image 726
Falcata Avatar asked Dec 22 '25 03:12

Falcata


1 Answers

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);
like image 187
paxdiablo Avatar answered Dec 24 '25 17:12

paxdiablo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!