[vtk-developers] help with cppcheck duplInheritedMember warnings

Ben Boeckel ben.boeckel at kitware.com
Mon May 8 08:48:48 EDT 2017


On Fri, May 05, 2017 at 18:31:53 +0200, Jon Haitz Legarreta wrote:
> The ivar being reported as a duplicate is not, in fact, a duplicate: both
> the parent class vtkChartMatrix and the child vtkScatterPlotMatrix define
> an internal class named PIMPL. And the ivar "Private" is an instance of
> that class.

vtkChartMatrix is doing PIMPL wrong. It is `protected`, not `private`. I
think that is likely the proper fix.

> I was not aware of the use of private implementations that PIMPL represents
> within the VTK context.

Usually, I've seen `<classname>Internal` instead declared outside of the
class itself, but these are usually `protected` so that subclasses can
use them. If `vtkChartMatrix::Private` has this intended use, it should
follow that pattern instead.

> BTW, I'm interested in knowing about the (need of/convenience) PIMPL
> classes. Is the use of such PIMPL classes documented somewhere?

In VTK? I don't think so. The idea is to hide the amount of data
necessary for completely internal data collection out of the header and
affecting `sizeof(class)` (an ABI break) or exposing too much (prone to
breaking API because users of the class rely on the wrong things). The
Wiki page is useful:

    https://en.wikipedia.org/wiki/Opaque_pointer

--Ben


More information about the vtk-developers mailing list