DRAFT document on coding conventions in kde libraries

Lubos Lunak l.lunak at suse.cz
Mon Mar 6 13:58:55 GMT 2006


On Monday 06 March 2006 09:40, Allan Sandfeld Jensen wrote:
> On Monday 06 March 2006 08:21, Andras Mantia wrote:
> > On Monday 06 March 2006 01:33, Allan Sandfeld Jensen wrote:
> > > On Sunday 05 March 2006 19:25, Frans Englich wrote:
> > > > * Mention that people should avoid C style casts. Especially in
> > > > headers but also in implementation. From my knowledge: C++ style
> > > > casts are stricter and therefore gives the compiler better options
> > > > for statically detecting errors, and in some cases invalid casts
> > > > are generated by C-style casts.
> > >
> > > I do not agree. I think it is more important to warn against
> > > dynamic_cast<> and recommend qobject_cast<> or static_cast<>/C style
> > > casts instead.
> >
> > What is your problem with dynamic_cast (aside that I read qobject_cast
> > is faster, but only for QObject derivate classes)?
>
> It is unreliable across shared libaries. If you have a non-QObject based
> heirachy you should implement your own type-system rather than rely on
> dynamic_cast.

 Or you should just fix it, it's required for things like exceptions too, and 
those you can't design your own (well, ok, you can ...). And it's in fact 
mentioned in kdelibs/TODO and it should be fixable.

-- 
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o.  e-mail: l.lunak at suse.cz , l.lunak at kde.org
Drahobejlova 27  tel: +420 2 9654 2373
190 00 Praha 9   fax: +420 2 9654 2374
Czech Republic   http://www.suse.cz/




More information about the kde-core-devel mailing list