[vtk-developers] Dashboard failures, vtkSetNGetMacro
David Gobbi
david.gobbi at gmail.com
Mon Mar 25 23:05:49 EDT 2013
Hi All,
I clicked on a dashboard compile error today and saw something that
was like finding a cockroach in my salad.
A new macro.
Someone snuck a new macro called vtkSetNGetMacro into vtkSetGet.h.
I won't go into the reasons why macros are bad. Every C++ programmer
already knows. In VTK, we generally try to keep our macros caged in
a little file called vtkSetGet.h where they have sat mostly unchanged
for a dozen years. We don't let our macros breed.
Here are problems with vtkSetNGetMacro:
1) It isn't, as its name suggests, the same as having a SetMacro and
a GetMacro. How is it different? It doesn't call "Modified" on the
object. And it's very important for Set methods to call Modified.
(To be fair, the documentation does state "this macro can be used on
non-vtkObject classes" but it should also state "this macro should
_not_ be used on vtkObject-derived classes").
2) The macros in vtkSetGet.h are hard-coded into the wrappers. This
is historical and will eventually be fixed. But for now, using a new
macro to define your class interface is likely to make your class
unwrappable.
3) The biggest problem, however, it is that it is a new macro, and if
people plan to add new macros, I think they should check with Berk,
Brad, or Will first.
- David
More information about the vtk-developers
mailing list