Would memory allocation also be hardware dependent and thus vary as well depending on what hardware the OS decides to support?
You mean like devices without MMUs? I think that might be the case but I'm not sure. Under Linux you need a special kernel and libc to handle such devices IIRC.
Because not every OS is an UNIX clone and C also targets bare metal.
- afaik freestanding C specifies no standard library at all (except pure headers,) so bare metal targets providing libc are going beyond the standard.
- I'm just saying it doesn't need to specify who implements the standard library. I've read the standard before and I don't really recall this coming up, I'm just assuming this assertion is accurate.
(And of course, the overwhelming reality is that libc is provided by none of the compilers except Microsoft C, since Clang and GCC tend to be used with glibc.)
There is a world beyond gcc, clang and MSVC.
Just out of my head, MikroElektronika, TI, Green Hills, Embarcadero, IBM, HP, Unisys, Intel, PGI.
Regardless, afaik OpenBSD and FreeBSD both ship libc as part of the operating system. It makes a lot of sense, really, because libc is bound to need to make syscalls, which differ strongly depending on the kernel, whereas the user interface of libc is pretty much the same across any operating system.