Issue
I am using Visual Studio 2019 and Ubuntu 20.04.3 LTS for my Windows Subsystem for Linux (WSL) (setup for WSL was done following this href="https://devblogs.microsoft.com/cppblog/c-with-visual-studio-2019-and-windows-subsystem-for-linux-wsl/" rel="nofollow noreferrer">MS dev post), and even with my Visual Studio's project
Configuration Properties > General
> Platform Toolset = GCC for Windows Subsystem for Linux
I get
Identifier "MAP_ANONYMOUS" is undefined
with a program such as
int main() {
int N = 5;
int* ptr = mmap(NULL, N * sizeof(int),
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
}
Only MAP_ANONYMOUS
is undefined, how can I fix this? I have tried changing the C language standard by going to my VS project's
Configuration Properties > C/C++
> All Options > C Language Standard = C11 (-std=gnu11)
per the recommendation of this SO post.
Solution
As soon as I posted this question, I found the solution. The solution is to set the C Language Standard correctly by doing
Configuration Properties > C/C++
> All Options > C Language Standard = C11(GNU Dialect)(-std=gnu11)
This can be selected using the C Language Standard drop down menu.
Answered By - Jared Frazier Answer Checked By - Marilyn (WPSolving Volunteer)