Page 1 of 1

C or C++

Posted: Wed Nov 14, 2001 6:25 am
by iwod
is what way is C better than C++ ( in terms of OS programming ), and on the other hand how is C++ better than C??

Re: C or C++

Posted: Wed Nov 14, 2001 11:04 pm
by Ranieri
Well, C is a very straightforward programming language, and it's possible to use it roughly as a glorified assembler if needed.

C++ has a lot of built in functionality that you might or might not want to use, but that adds a lot of complication in the context of standard library-less systems as most kernels.

I reccomend you have a look at the FAQ, it does a resonably good job of explaining how to use c++ for kernel development.
It basically boils down to having to explicitly telling the linker not to link with the c++ library and either staying away from dynamic allocation or defining your own.
Of course, you will not be able to use STL or similar libraries unless you include them.

So while using C++ might make for a cleaner design, it will also complicate matters a bit.

Re: C or C++

Posted: Thu Nov 29, 2001 10:28 pm
by anpe
Hi,
IMHO, C++ is a bad choice for the kernel itself as the C code generated is much. I think you've got more control on the code that is generated when you write it in C.