[vtkusers] vtk Marco usage

David Thompson david.thompson at kitware.com
Wed Sep 16 01:00:10 EDT 2015

Hi Marco,

> can you explain with clearly about vtkStandardNewMacro and how does it work , what's it's usage ?

Every concrete class that inherits vtkObject is expected to implement a class-static method named New() that returns an instance of the class (since the constructor and destructor are protected). This macro can be placed in each class's implementation file to provide the implementation of that method. (You still have to declare the method in the header file.) Normally, the macro simplifies to "return new X;" (where X is the name of your class). However, when VTK_DEBUG_LEAKS is turned on, some additional bookkeeping is done for debugging memory leaks.

You can look at how the macro is defined in Common/Core/vtkObjectFactory.h.


More information about the vtkusers mailing list