Reputation: 652
I'm encountering issues when trying to compile my C code on Win64. More specifically, the compiler cannot find the sys/mman.h
header, which I understand is found in Unix environments only.
I already know this is deals with memory allocation.
Is there an equivalent for Windows I can use in order to port the code (first time trying)?
Code in that causes issues:
/* Allocate memory required by processes */
buf = (int*) malloc (sizeof(int));
if (!buf)
{
perror("Error");
free (buf);
return -3;
}
/* Lock down pages mapped to processes */
puts("Locking down processes.");
if(mlockall (MCL_CURRENT | MCL_FUTURE) < 0)
{
perror("mlockall");
free (buf);
return -4;
}
Upvotes: 6
Views: 21774
Reputation: 11
I was able to get around the issue by using g++ under cygwin, making sure the g++ came from the cygwin installation (the same version specified from the installer) and not the current compiler under windows.
Upvotes: 0
Reputation: 2085
You should look at the mman-win32 library. But as @Mgetz pointed out, a more simple way is to look at the VirtualAllocEx
functions and try to adapt your code.
Upvotes: 6