C++ standard library support

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
meh
Member
Member
Posts: 52
Joined: Sun Oct 21, 2007 4:30 pm

C++ standard library support

Post by meh »

Are there any tutorials on how to enable support for the C++ standard library in my kernel?
label_3162073
Posts: 6
Joined: Sat Jul 14, 2007 3:05 am

Post by label_3162073 »

e.. it seem to be impossible..
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

You'd have to write all your own template classes. The c++ standard library depends on a hosted environment.
meh
Member
Member
Posts: 52
Joined: Sun Oct 21, 2007 4:30 pm

Post by meh »

Are there any other libraries that I can use with my operating system?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

1. Your kernel is standalone - no libraries can be ported to it.
2. The programs that run on your OS (hosted by the kernel) can use libraries. Newlib is a good one to use (also libstdc++ can be used).

Notice they can only be used outside the kernel. That's what makes OS programming so interesting.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: C++ standard library support

Post by pcmattman »

You'd have to have a complete port of the C library first (and I mean complete) first. Not to mention the fact that the C++ STL is apparently a nightmare to port.
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

AusZero wrote:Are there any other libraries that I can use with my operating system?
Try STLport, or Boost C++ Libraries. Although Boost technically isn't a C++ STL implementation, it's considered an extension of it and (I think) it can be used without an STL library.

EDIT: I didn't see "in my kernel". It's still possible. I've ported some things like malloc and strings to my kernel. Just replace the system calls with function calls!
My OS is Perception.
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: C++ standard library support

Post by jnc100 »

AusZero wrote:Are there any tutorials on how to enable support for the C++ standard library in my kernel?
Well, if you follow the instructions at OS Specific Toolchain you'll end up with a libsupc++, libstdc++ and an include directory with all the stl stuff in. There are obviously a lot of dependencies on libgcc (which you also get for free) and libc (which you get, but it is tailored for userspace, so writing a smaller kernel version might make more sense). I have never tried stl in a kernel, but can't see why it shouldn't work (as long as you implement malloc, strcpy etc), but I can vouch for the functioning of libsupc++, including exceptions and rtti, all within kernel space within a few lines of startup (although you need a simple malloc, e.g a stack-based one, before your virtual memory manager starts).

Regards,
John.
Post Reply