I've been interested in programming an operating system for some time. Delving through a few different sites, I've come across an interesting concept (to paraphrase): if you start writing your bootloader with #include, you've already made a fatal mistake.
I've gone through K&R, and the entire book includes it throughout each lesson. Having used it throughout learning C, I don't know what I've learned that uses stdio and what doesn't. What can you do in C without stdio?
The C standard (ISO/IEC 9899:1999) recognizes two types of implementation (§4 Conformance, ¶6):
Freestanding - where the implementation (compiler plus library) only provides seven headers:
<float.h>
<iso646.h>
<limits.h>
<stdarg.h>
<stdbool.h>
<stddef.h>
<stdint.h>
These provide basic facilities for the language and declare no functions (the facilities in <stdarg.h>
are explicitly defined as macros in the standard). Note that it does not include complex numbers.
Hosted - where the implementation provides the complete library defined by the standard.
The whole point of a freestanding implementation is to allow you to write any code you need unencumbered by the standard library in general, and the standard I/O functions specifically. The downside is that you not only can but must provide those functions - or make use of alternatives provided by the implementation. Note that in a freestanding implementation, the entry point for the program need not be called main
.
What you are seeking is a freestanding implementation - or to use the freestanding portion of a hosted implementation. You will use headers (unless you're insane), but they probably won't be the standard C library headers other than those listed for use with a freestanding implementation.