0

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 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.

Jared Frazier
  • 413
  • 1
  • 4
  • 10

2 Answers2

1

If you are using VS Code, just go to the configuration settings under where you see the c version and enter image description here. Choose gnu11 and c++11 on the option underneath. This should automatically clear the error.

Egemen Çiftci
  • 699
  • 5
  • 13
0

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.

Jared Frazier
  • 413
  • 1
  • 4
  • 10