Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ runtime

Started by Witchcraven Nov 22, 2003 at 12:45 AM 5 replies 500+ views
Original Post
Witchcraven
Witchcraven
I need to write a custom runtime library for c++ (the runtime does operations such as new and delete). This is for kernel stuff. I could write in c++ without using runtime features (or plain C), but I would really like to. Anyway, my compiler is gcc 3.0. I dont even know if it is possible to write a custom runtime. But if it is, does anyone know?
--------------------------I present for tribute this haiku:Inane Ravings OfThe Haunting JubilationA Mad Engineer©Copyright 2005 ExtrariusAll Rights Reserved
Fruny
Fruny
Start here. Good luck.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Witchcraven
Witchcraven
hmmm. would probably be less work just to use C.
--------------------------I present for tribute this haiku:Inane Ravings OfThe Haunting JubilationA Mad Engineer©Copyright 2005 ExtrariusAll Rights Reserved
Fruny
Fruny
quote:
Original post by Witchcraven
hmmm. would probably be less work just to use C.


C has a runtime too, you know. malloc() and free() are library functions.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Witchcraven
Witchcraven
THats not quite the same. Those are not built into the langauge. You could just as easily name malloc() get_me_sex(). Programs would just need to use get_me_sex() instead of malloc(). Before this thread, I didnt know if new/delete were built into the compiler or what (I dont really use c++), but would like to in this kernel. Plus I know how to replace malloc if I had to. Just compile without libc,which I do anyway for kernel work, and write your own like any other function.
--------------------------I present for tribute this haiku:Inane Ravings OfThe Haunting JubilationA Mad Engineer©Copyright 2005 ExtrariusAll Rights Reserved
Fruny
Fruny
quote:
Original post by Witchcraven
Before this thread, I didnt know if new/delete were built into the compiler or what (I dont really use c++), but would like to in this kernel.


Well, if all you want is replace new and delete, you can write your own too. The functions that take care of the memory allocation are named operator new, operator new[], operator delete and operator delete[].

The names are built into the language. The functions are not.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Witchcraven
Witchcraven
Do you think if I were to replace new and delete it would work without the runtime? Or do they need to be replaced in the runtime?
--------------------------I present for tribute this haiku:Inane Ravings OfThe Haunting JubilationA Mad Engineer©Copyright 2005 ExtrariusAll Rights Reserved

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.