[vtk-developers] const correctness

David Gobbi david.gobbi at gmail.com
Thu Feb 10 15:05:24 EST 2011


On Thu, Feb 10, 2011 at 12:15 PM, Sean McBride <sean at rogue-research.com> wrote:
>
> From my perspective, as a client of VTK's public API, the advantage is
> that sometimes I have something that really is const, say a const string
> like "foo", and I need to pass it to a VTK API that takes char*.  If VTK
> mutates the buffer I've passed, I'll crash. If it doesn't mutate, I'm
> ok, but the compiler will rightly complain that I'm implicitly casting
> away constness.

This is something that I agree with 100%.  All "char *" parameters
should be changed to take "const char *" unless they are intended to
modify the string.  In fact I'm pretty sure that Ken Martin went
through and fixed a whole bunch of these back in 2001 or so, but
several more have crept in over the years.  I could live with the
minor backward compatibility issues of such a change.  Tom's broader
changes are something else, though.

 - David



More information about the vtk-developers mailing list