cposixglibclibcansi-c

What are the differences between the various C standard library implementations


While I was researching how fopen and moreover the structure FILE are built I found out it wasn't all just GNU libc. I began to look closer at the various implementations such as Google's Bionic, Musl, Newlib and several others. Having only been aware of Musl and up until now my understanding was that it was just a more optimized version of gnu libc. I hadn't given much thought about how, or if, they are allowed to differ and how they are possibly similar with the same respect.

Specifically how does the Posix and ANSI C standard dictate the various implementations? Meaning are all fopen and FILE (all libc functions/structures) determined to be built more or less the same? Or is it that they are opaque and just held to the "standard" of operating the same (return values and interfaces exposed)?

Intuitively, I would think its as I have described but maybe Musl is literally built more efficiently and optimized from compilation/linkage.

Any insight is greatly appreciated.


Solution

  • Specifically how does the Posix and ANSI C standard dictate the various implementations?

    They don't, they only dictate the expected behavior of calling each of the library's functions.

    What are the differences between the various C standard library implementations

    You can split this into 2 categories:

    Of course an implementation of the standard C library can attempt to be portable and support multiple environments (e.g. 32-bit and 64-bit code) and multiple operating systems (e.g. with lots of #ifdef ...); so there's also differences in which targets the source code of a standard C library tries to support.