Why not use C++?

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.
Post Reply
dc0d32

Why not use C++?

Post by dc0d32 »

Can somebone please TELL MY WHY I SHOULD ***NOT*** USE C++ FOR KERNEL DEVELOPMENT . what are the pros and cons of it?

I have a C kernel up and running :), it is for i586+, has features such as user mode tasks with preemptive multitasking, rudimentary device driver support, paging etc. and some basic obvious things.

I know C++ language well. I won't be using exceptions. i also have coded basic functions to support some other C++ features such as global object construction etc., and the code for operators new/delete won't be much bigger [i have kmalloc()]. the test kernel with iostream and cout-cin works well.

Thanx.
[edit by Candy]Don't shout in your topic title[/edit]
AR

Re:WHY NOT USE C++

Post by AR »

I don't see why not, C++ operates at around the same level as C except that a lot of it's OOP features require runtime support. I'm writing a bootloader in C++ and have prototyped several kernels in C++, as long as you avoid things like virtuals and exceptions you shouldn't have much trouble.
dc0d32

Re:WHY NOT USE C++

Post by dc0d32 »

Thankx
then how do i go for it. can you please draw an example overview of the design? i had thought of one, but was not satisfactory.
AR

Re:WHY NOT USE C++

Post by AR »

Example design of a kernel? The structure is up to you but I like to divide the features into logical units and group them in namespaces, I rarely use classes to avoid the runtime support problems but you can use classes if you want just don't put in any virtual functions [If you want virtuals you'll have to look up the hidden dependencies in libsupc++ and implement them].

I'm currently working on the bootloader though, my kernel's design will depend on what features the loader provides.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:WHY NOT USE C++

Post by Neo »

prashant wrote: Thankx
then how do i go for it. can you please draw an example overview of the design? i had thought of one, but was not satisfactory.
http://www.osdev.org/osfaq2/
Only Human
dc0d32

Re:WHY NOT USE C++

Post by dc0d32 »

do virtual calls really need something extra? i had written a test kernel with an abstract base class and 3 derived classes, and the vcalls worked very well , i had to fake the __cxa_pure_virtual for the gcc.
AR

Re:WHY NOT USE C++

Post by AR »

I've just had problems with dependencies on _Z... things that pop up occasionally, sometimes they do sometimes they don't and I just haven't bothered to look up how to resolve them yet.
Post Reply