C++ OS Programming

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Cmaranec
Member
Member
Posts: 45
Joined: Sat Oct 21, 2006 1:07 pm
Location: Czech Republic

oh?

Post by Cmaranec »

I am totally beginner. WHAT i must do for my OS??? Please concretely. :arrow:
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

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...
Cmaranec
Member
Member
Posts: 45
Joined: Sat Oct 21, 2006 1:07 pm
Location: Czech Republic

thx

Post by Cmaranec »

Thanx, i am newbie on osdev. In C++ i am good :D .
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

bluecode 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>
http://svn.sourceforge.net/viewvc/atlan ... iew=markup
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 ;)
Well, actually I cheated on string, it's a blank implementation. It gets stuff compiling though :).

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 :)).
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...
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).
Cmaranec
Member
Member
Posts: 45
Joined: Sat Oct 21, 2006 1:07 pm
Location: Czech Republic

Post by Cmaranec »

Wow, thanks. I find this codes in other open source projects. I didn't find anything :lol:
Post Reply