[haiku-development] Re: GCC 2.95 and the STL

  • From: Brecht Machiels <brecht@xxxxxxxxxxx>
  • To: "haiku-development@xxxxxxxxxxxxx" <haiku-development@xxxxxxxxxxxxx>
  • Date: Sun, 14 Mar 2010 19:36:20 +0100

At Sunday, 14-03-2010 on 15:01 Ingo Weinhold wrote:
> > > BTW, using the STL (beyond stuff that is fully defined in the headers) 
> > > for an
> > > FS in not such a good idea, anyway, since you won't be able to use it in 
> > > the
> > > kernel.
> > 
> > Are there any replacements for the STL list, vector and map classes? IIRC, 
> > other filesystems in the Haiku tree use custom container classes.
> 
> Indeed, most use the private headers/private/kernel/util classes.
> 
> > I suppose I can use BString instead of std::string.
> 
> There is no BString in the kernel. For the userlandfs I wrote a very simple 
> immutable String class, but if you want your strings e.g. with 
> DoublyLinkedList you'll need your own class anyway (including a list link).

Is there any sort of documentation for these classes? It's not clear to me (but 
I haven't read the code thoroughly) why the stored element needs to be "aware" 
of the container, as the STL containers do not require this. I'm sure there's a 
good reason for it though :)

> > > Moreover, std::list uses non-intrusive list-links which require memory
> > > allocations. Since the STL container interfaces usually don't have another
> > > way of reporting failed memory allocations than throwing std::bad_alloc,
> > > using those classes in the kernel is a no-go.
> > 
> > I'm also making use of RTTI, so that would also be a problem for a 
> > kernel-space FS.
> 
> RTTI is available in the kernel.

I'm not sure where I got this idea. Did this change recently? Maybe I 
incorrectly made this assumption seeing an -fno-rtti in some FS code. Or maybe 
I'm confusing it with something else. Something special about casting in the 
kernel perhaps?

Thanks,
Brecht

Other related posts: