DRAFT document on coding conventions in kde libraries

Allan Sandfeld Jensen kde at carewolf.com
Mon Mar 6 08:40:44 GMT 2006


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. 

`Allan




More information about the kde-core-devel mailing list