Stricto sensu, a portable (hosted) C99 program not using the standard library is even unable to make any input/output, or probably make any observable side effect. And you won't even be able to allocate any data in the heap (like malloc
does). BTW a libc is sort-of required by any C99 hosted implementation; you want a freestanding library for C (and it would by definition be "implementation specific"; indeed it could use OS specific services in an implementation specific way. See also this).
On old Linux (and IIRC, SVR4 e.g. SunOS 5), there used to be some libsys
which only interfaced the syscalls(2). AFAIK, it is deprecated, and I cannot find it.
Some libraries (like Glib from GTK, ....) are offering equivalent of most standard C library functions (but they are expecting some libc, i.e. a hosted POSIX system).
Notice that you might consider using musl-libc and perhaps remove the functions you don't want from it. You could also consider using some libc providing a subset of the standard, e.g. dietlibc. See also wikipage on C standard library.
BTW, you might have issues in coding in C any user-land Linux application which does not use the libc (e.g. because of crt0).
The strange thing is that I cannot today even name a free software language which is not using somehow C. In principle that could be possible (e.g. on Linux compiled to only call the syscalls), but I don't know anything like that.
Notice however that (at least on Linux) if you code a statically linked binary which does not call any standard C function, that binary will embark only a small portion of the libc (the one reachable from crt0).
Some standard library facilities (like setjmp(3) or stdarg(3)...) usually require -or at least profit from- some compiler magic (even malloc
, printf
, free
do with recent GCC). Some of the standard library functions are not implementable in portable C.
If using gcc
don't forget the -ffreestanding
option to gcc
in that case. See this.
Refer to n1570, a (draft) C11 standard almost similar to the ISO one, or to n2573, close to the C20 standard. See also Modern C and this C reference website. Examples of freestanding open source applications includes the Linux kernel, but there are many others on github or gitlab and mentioned on OSDEV, but also for Arduino or RaspberryPi. I recommend downloading their source code and studying it for inspiration.
NB: you could consider that there are two dialects of the C99 language: the hosted C which contains standard libc functions like fprintf
, malloc
, etc... and starts with main
... and the freestanding C which does not contain them (but do contain setjmp
etc...) and has no starting conventions.