Q:

Why is unistd.h different in MSYS2 and mingw-w64-x86_64-toolchain?

I am running CLion which recommended MinGW. The most current one seems to be MSYS2. At first CLion didn't find gcc, cmake and so on. To do that I had to install mingw-w64-x86_64-toolchain, which creates a mingw64 folder in my msys64 (MSYS2 installation folder) folder.
A software I am trying to compile requires either MSVC functions or POSIX ones, like sysconf. But sysconf is undefined, at least in the unistd.h of mingw-w64-x86_64-toolchain. In the main unistd.h of MSYS2 itself it is available.
So, what's the big difference? Why aren't they the same?

A:

The MSYS2 environment provides two toolchains to target two different runtimes on Windows.

The msys2 toolchain which lives in /usr makes programs that depend on the msys-2.0.dll POSIX emulation layer.
The MinGW toolchain which lives in /mingw32 or /mingw64 creates native Windows programs that basically only have access to the features provided by Microsoft's headers and lirbaries, and not much else.  These programs are easier to redistribute to other users and generally run faster.

If you really need a lot of features of POSIX, you'll probably not be able to use the MinGW toolchain.

