Hi, Wasn't subscribed to the wiki list, but I saw this thread on the archive and wanted to chime in a bit.
On Mon Sep 12, 2022 at 9:09 PM CEST, Lancia Greggori wrote: > How is it possible to write a C library with absolutely no dependency on > libc? For libraries it's not that difficult depending on the scope of the library. One such library that I really like is optparse [0], it has no dependency whatsoever. The author of optparse also has a very nice article on how to write minimalistic C libraries [1]. > Simply pass `-nostdlib' and do not include any standard headers. > However, none of this is done in monocypher[1], thus it actually depends on > libc (which isn't a problem). The C standard defines 2 different types of execution environment [2], "hosted" and "freestanding". <stdint.h> and <stddef.h> are part of the freestanding environment [3] thus there is no dependency on libc (freestanding headers are typically provided by the compiler). [0]: https://github.com/skeeto/optparse [1]: https://nullprogram.com/blog/2018/06/10/ [2]: https://port70.net/~nsz/c/c11/n1570.html#5.1.2 [3]: https://port70.net/~nsz/c/c11/n1570.html#4p6 - NRK
