Closed
Description
We use libc functions on various Windows routines, but they are just convenient wrappers of WinAPI and there's usually no critical reason to use them.
Also, the wrapper has its own runtime state so it adds additional complexity, so it's better to use WinAPI than libc functions in general.
For example, msvcrt has libc errno
variable, but it's not Windows' native error code value (GetLastError()) therefore unrelated to std::os::errno()
.
Another example is that msvcrt manages its own "C locale", distinct to Windows locale.
Here's some libc uses (not complete):
rt/rust_builtin.c
: e.g.gmtime
,localtime
. (seems like they are unused now)liballoc/heap.rs
usesmalloc
,realloc
,free
if jemalloc is disabled. HeapAlloc is better?libstd/sys/windows/
: e.g.fs.rs
usesopen_osfhandle
.
See also Support: Win32 Equivalents for C Run-Time Functions.