1

So I wanted to use the mremap function to more easily work with memory mapped files but an implicit declaration error is raised

addr = mremap(addr, len, len_file, MREMAP_MAYMOVE);

I do include the required libraries, if i didnt the line

addr = mmap(NULL, len_file, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0);

would raise the same error.

My current header has the libraries that are pointed as required

#include <sys/mman.h>
#define _GNU_SOURCE
melpomene
  • 84,125
  • 8
  • 85
  • 148
Goamaral
  • 299
  • 2
  • 4
  • 15

1 Answers1

2

The order is incorrect here:

#include <sys/mman.h>
#define _GNU_SOURCE

You must define _GNU_SOURCE before including the headers:

#define _GNU_SOURCE
#include <sys/mman.h>
melpomene
  • 84,125
  • 8
  • 85
  • 148
P.P
  • 117,907
  • 20
  • 175
  • 238