C Library: Difference between revisions

Jump to navigation Jump to search
Added clarification of the term "freestanding"
[unchecked revision][unchecked revision]
m (removed extra commas, added one bullet point)
(Added clarification of the term "freestanding")
Line 1:
{{stub}}
 
The ''C standard library'' provides basic functionality such as string manipulation, basic I/O, and memory allocation. Whether you're writing a kernel in C or you plan on supporting existing C programs, you'll want to use it.
 
There are three situations where you are likely to want to have one:
 
# If you want to have some traditional C functions that you can use inside your kernel (especially printf), then you will need to link a C library into your kernel when you build it.
# Most applications in userspace expect to be able to access traditional C support functions. These functions are usually supplied to userspace in the form of a "runtime C library", that can be dynamically linked into user applications at runtime.
# The C library header files are used extensively during C and C++ compilations.
 
==Versions==
 
The C standard describes two versions of theeach standardC library: the complete "hosted" library and the "freestanding" one,. providingThe onlyso-called a subset of the hosted"freestanding library" thatconsists doesn'tof needa tohandful interactof withheader thefiles, environment.which Systemcontain softwareonly shoulddefines typicallyand usetypedefs theand former,are whileused applications should have theonly latterduring availablecompilations.
 
The <tt>__STDC_HOSTED__</tt> macro expands to <tt>1</tt> on hosted implementations, or <tt>0</tt> on freestanding ones. The freestanding headers are: <tt>&lt;float.h&gt;</tt>, <tt>&lt;iso646.h&gt;</tt>, <tt>&lt;limits.h&gt;</tt>, <tt>&lt;stdalign.h&gt;</tt>, <tt>&lt;stdarg.h&gt;</tt>, <tt>&lt;stdbool.h&gt;</tt>, <tt>&lt;stddef.h&gt;</tt>, <tt>&lt;stdint.h&gt;</tt>, and <tt>&lt;stdnoreturn.h&gt;</tt>.
Line 14 ⟶ 20:
 
There exists a myraid of implementations of the standard library avalible at your disposal.
UsingThere are several open-source C library packages avaialble, and using one may be a viable solution butfor you. All of them will require some degree of modification to suit your needs. You may instead wish to roll your own, but keep in mind that a good C library implementation often requires 10 years or more to create.
 
There is a comparison table of some of these at: [http://www.etalabs.net/compare_libcs.html]
Line 31 ⟶ 37:
* Under active development, and not at full working release 1.0 yet
* Creative Commons Zero license (basically public domain)
* Good for linking into kernels
* [http://pdclib.e43.eu/ PDCLib website]
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu