C++ operating system

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.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: C++ operating system

Post by Troy Martin »

puts() and gets() are the easiest!
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: C++ operating system

Post by VolTeK »

i use alot of commas to declare pauses in my sentence, wrong but eh ill do it anyway, thanks for answering my questions
JJeronimo
Member
Member
Posts: 202
Joined: Wed Oct 18, 2006 3:29 pm

Re: C++ operating system

Post by JJeronimo »

ru2aqare wrote:I would argue with that. No, you can't use the cin and cout that comes with your compiler or C++ library. But you can always write it for yourself and define it to do whatever you want it to do - send ouput to serial port, to screen or whatever.

As for exactly how it can be done, I don't know - I don't use many features of the C++ language in my kernel. But there should be a way to do it.
As... for example... implementing a simple factory to create a stream from the GRUB's argument string, and then use it as the kernel's cout? :-)

JJ
JJeronimo
Member
Member
Posts: 202
Joined: Wed Oct 18, 2006 3:29 pm

Re: C++ operating system

Post by JJeronimo »

Alboin wrote:
But it would take a lot of work
Kind of off topic, but cout and cin are not really that tricky to implement. If anything, they're easier and less hacky than their C counterparts.
I agree. Printf uses a very complicated convention to format the strings, where cout just uses operator association to convey the same result.
Variadic functions is a somewhat obscure feature of C that is smartly avoided by the C++ streams.


I've read some minutes ago a post that is 4 months old about C++ and it's usefulness for OSDev. It was quite outdated, so I did not comment the topic there.

I think OOP may be useful in OSDev (including perhaps kernel development) much the same way that it's useful in other areas of computer programming. IMHO, C++ is the proof that a language may be very OOP-ish and yet don't force the programmer to pay a huge overhead.

I also think that saying that exception handling is too much overhead for OSDev is not reasonable. That overhead is very very occasional (only when you install the handler, and when the exceptional condition is met (i.e. during the stack unwinding), which is by definition rare).
I miss exception handling in C. Of course, however, there are alternatives (errno and friends), but EH is much more elegant, cause it's a clean way to separate the "normal" flow from the "exceptional" flow.
(I know there are some EH libs for C, and that some use setjump/longjump to implement it.)

JJ
Post Reply