When we are writing a Rust library, what is the difference between normal std mode with no_std + alloc + libc?
I'm not so familiar with bare metal programming, but as far as I understand, for a Rust library, the main difference between core and std is platform-specific functionalities. So if we link to libc, are there any situations where the library works with no_std + alloc + libc, but not with std? In other word, if we are using no_std + alloc + libc in a Rust library, is it better just switching to std?
So if we link to libc, are there any situations where the library works with no_std + alloc + libc, but not with std?
If by “libc” you mean the platform C standard library and not the Rust library crate libc, then: yes, this could work on platforms where Rust std has not yet been ported.
You get the safety of std's safe wrappers for platform functionality. And possibly easier compatibility with platforms that don’t use C or POSIX standards but I don’t know if there are any of those. (I should really look into how WASI works some day.)