Last updated
Last updated
A kernel can be written in C++ just as it can be in C, with the exception of a few pitfalls that come with using C++ (runtime support, constructors, etc).
The compiler will assume that all the necessary C++ runtime support is available by default, but as we are not linking libsupc++ into your C++ kernel, we need to add some basic functions that can be found in the file.
Caution: The operators new
and delete
cannot be used before virtual memory and pagination have been initialized.
The kernel code can't use functions from the standard libraries so we need to add some basic functions for managing memory and strings:
In the next step, we're going to define different types we're going to use in our code. Most of our variable types are going to be unsigned. This means that all the bits are used to store the integer. Signed variables use their first bit to indicate their sign.
Compiling a kernel is not the same thing as compiling a linux executable, we can't use a standard library and should have no dependencies to the system.
For x86 architecture, the followings arguments will be used for gcc/g++/ld:
These functions are defined in , ,
Our will define the process to compile and link our kernel.