C++ Bare Bones: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m Interwiki |
Cleaned up some inconsistency on main() / kmain() / Entry.cpp / kernel.cpp. Removed C/C++ loader code - with no stack set up, calling C code isn't that smart. See discussion. |
||
Line 81:
==Calling Constructors & Destructors==
The constructors have to be executed as quickly as possible after booting your kernel (just make sure you execute them before you actually use any of the objects that require them). Destructors should preferably be called somewhere before your kernel shuts the computer down or simply returns from the
Below you'll find a couple of examples on how to do this.
Line 106:
jb .body
call
static_dtors_loop:
Line 142:
jb 1b
call
# calling static destructors
Line 159:
</source>
==
Now, all that is needed is to declare C style linkage for the kernel entry function, so that its name will not get mangled to C++ linkage style and you can call it from your multiboot header Assembly file:
<source lang="cpp">
extern "C" void
{
// write your kernel here
Line 195 ⟶ 177:
</pre>
'''loader''' should in its turn call "
==Compiler Options==
Line 201 ⟶ 183:
<source lang="bash">
g++ -o
</source>
|