[openbeos] Re: C++ in the kernel

  • From: "Ingo Weinhold" <bonefish@xxxxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Sun, 23 Feb 2003 13:23:54 +0100 CET

Tyler Dauwalder <tyler@xxxxxxxxxxxxx> wrote:
> Could someone explain to me which features of C++ I'm not allowed to 
> use in the kernel, preferably with an explanation of why, if 
> possible? And is it the same everywhere, or are certain parts more 
> restricted than others?

I'm actually not very confident, but I'll gladly share my little 
knowledge.

> OTOH, if someone feels like doing an exhaustive newsletter article on 
> the topic, I'm happy to wait <cough>. :-)

The second newsletter article Charlie was referring to is a good 
introduction (does anybody know, where to get the sample code?). I'd 
like to have more details, though. I've been trying for months to 
convince Axel to write an article, but he's just too lazy. ;-)

You might also want to have a look at src/add-ons/kernel/file_systems/
bfs/cpp.{h,cpp}.
I think, cpp.cpp should be linked into the kernel and cpp.h made 
available as public kernel header.

> Here's my impression of the current blacklist (some of these have 
> been explained to me before, but the explanations didn't really stick 
> :-):
> - exceptions: not sure why

The article explains a bit why.

> - virtuals: not sure why

It seems, they can be used. Cf. src/add-ons/kernel/file_systems/bfs/
Query.cpp.

> - STL: not sure why

Mmh, uses exceptions for one. And comes with a dynamic library.

> And here are a couple I'm specifically curious about:
> - new and delete

No problem. The operators have to be overridden as in cpp.h. I dislike 
the `#define new new (_dontthrow)' there, though. And I don't think 
`extern nothrow_t _dontthrow;' is needed, for `nothrow' should be 
defined anyway.

> - templates (and no, I don't need to know who thinks templates are 
> God
>   given and who thinks they're the spawn of the devil, just whether I
>   can use them or not, thank you :-)

Can be used without restriction. This is a compile time only feature.

CU, Ingo


Other related posts: