C++ OS Programming
Are you a total C++ newbie or just new to osdev?
Point is, if your a c++ newbie, than don't try to write an OS in C++. It's just to complex. If you want an std::string class, then write your own, which includes the following things:
* std::allocator template (you need to write your own new/delete/malloc/free/calloc here)
* std::char_traits template and the specialisation for char (and in case you need any of the c library functions here, you also have to write your own, e.g. strlen, strcpy, ...)
* std::basic_string template and the specialisation for char
* typedef the basic_string<char>
Yeah, pretty heavy, ain't it? So if you don't know your language _in_ _detail_ , then go and learn this first. You can not handle these two things at once. You will end up in debugging session darker than a black hole not just the normal dark than night sessions
Another point is that you can not use exceptions (no try, catch, throw), RTTI (= Runtime type-information, no dynamic_cast, no pure virtual functions) and memory management (new, delete and the placement and array equivalents) until you wrote your own functions for this, which depends on the compiler...
Point is, if your a c++ newbie, than don't try to write an OS in C++. It's just to complex. If you want an std::string class, then write your own, which includes the following things:
* std::allocator template (you need to write your own new/delete/malloc/free/calloc here)
* std::char_traits template and the specialisation for char (and in case you need any of the c library functions here, you also have to write your own, e.g. strlen, strcpy, ...)
* std::basic_string template and the specialisation for char
* typedef the basic_string<char>
Yeah, pretty heavy, ain't it? So if you don't know your language _in_ _detail_ , then go and learn this first. You can not handle these two things at once. You will end up in debugging session darker than a black hole not just the normal dark than night sessions
Another point is that you can not use exceptions (no try, catch, throw), RTTI (= Runtime type-information, no dynamic_cast, no pure virtual functions) and memory management (new, delete and the placement and array equivalents) until you wrote your own functions for this, which depends on the compiler...
http://svn.sourceforge.net/viewvc/atlan ... iew=markupbluecode wrote:If you want an std::string class, then write your own, which includes the following things:
* std::allocator template (you need to write your own new/delete/malloc/free/calloc here)
http://svn.sourceforge.net/viewvc/atlan ... iew=markup* std::char_traits template and the specialisation for char (and in case you need any of the c library functions here, you also have to write your own, e.g. strlen, strcpy, ...)
http://svn.sourceforge.net/viewvc/atlan ... iew=markup* std::basic_string template and the specialisation for char
* typedef the basic_string<char>
Well, actually I cheated on string, it's a blank implementation. It gets stuff compiling though .Yeah, pretty heavy, ain't it? So if you don't know your language _in_ _detail_ , then go and learn this first. You can not handle these two things at once. You will end up in debugging session darker than a black hole not just the normal dark than night sessions
Still, I can pretty much confirm that most of OS dev stuff is pretty hard to do, and it's very much increasingly easier when you accept other people's code. I refuse to accept anything except for a very few types of code, so there's only two files in my archive that contain code that somebody else touched. If you accept the default implementation and the license that comes with it (mostly the second for me), you can reuse the code. The extreme of course is just plain using Windows, the other extreme is not using any code that anybody else wrote. I'm going for the second, most sane people go for the first. Anybody not completely mad goes for something in between (and if you really are mad, I'd like to meet you ).
Yep. You can also find very small example code for this in the same svn archive as the above code. They're all still untested, as I'm busy with the kernel and bootloader first. The bootloader is ok (except for a few bits), the kernel is still active work for me (right now, except that I'm websurfing).Another point is that you can not use exceptions (no try, catch, throw), RTTI (= Runtime type-information, no dynamic_cast, no pure virtual functions) and memory management (new, delete and the placement and array equivalents) until you wrote your own functions for this, which depends on the compiler...