Re: [wiki] Monocypher rocks!

From: Laslo Hunhold <dev_AT_frign.de>
Date: Mon, 26 Sep 2022 11:12:32 +0200

On Sat, 24 Sep 2022 02:48:23 +0600
NRK <nrk_AT_disroot.org> wrote:

Dear NRK,

> 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).

thanks man, you inspired me to refactor libgrapheme a tiny bit so it
also is now a freestanding[0] library. It goes to show that you can
achieve this also for non-trivial applications or where you might not
expect the possibility.

With best regards

Laslo

[0]:https://git.suckless.org/libgrapheme/commit/8a7e2ee85f0a2824e48e85e57534c5b18113cf07.html
Received on Mon Sep 26 2022 - 11:12:32 CEST

This archive was generated by hypermail 2.3.0 : Mon Sep 26 2022 - 11:12:52 CEST