Siyuan Ren Siyuan Ren - 1 year ago 123
C Question

What are the POSIX like functions in MSVC's C runtime?

Today I stumbled to MSDN's documents about Visual C++'s C runtime (example: and find to my surprise a lot of functions that look just like POSIX syscalls:

, ..., except being prefixed with
. Are these functions just wrappers to Windows API? Are they only usable with the POSIX subsystem? Are they deprecated/going to be deprecated?

Answer Source

These functions are wrappers around Win32 APIs. You don't need to have the POSIX subsystem to use them. They are not likely to disappear - Microsoft takes backwards compatibility very seriously.

You can find the source code of the MS CRT in "\Program Files (x86)\Microsoft Visual Studio X.0\VC\crt\src". E.g. you can see that _dup2 is calling DuplicateHandle and _stat is using FindFirstFileEx.

As for why they got the underscores, I could not find an official reason, but I suspect it's probably because these functions don't provide full POSIX compliance.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download