[Insight-developers] vtk2itk fixed

Bill Hoffman bill.hoffman@kitware.com
Mon, 09 Jul 2001 17:29:22 -0400


I have finally found the problem with vtk2itk.   
(do a cvs update to get the new vtk2itk.cxx)

In an itk header file we had a #undef GetClassName to get around the microsoft 
compiler problem with GetClassName.   During debug builds, VC++ has a #define 
GetClassName GetClassNameA in windows.h.  So, if you do not include windows.h 
in all of your files, like in Insight, you can end up with linker errors:

class foo
{ 
const char* GetClassName();
...


#include "foo.h"
#include <windows.h>

main()
{
foo f;
f.GetClassName();  // redefined to GetClassNameA by windows.h
// this compiles, but does not link because foo did not include
// windows.h when it was compiled, so the real name is in the library.
}


The problem with vtk2itk caused extra virtual functions to be added to
the VTK classes, and caused run time errors.

I did a re-order of the #includes in vtk2itk as a quick patch, but
this brings up a bigger issue.   I think that we will have to stop using
GetClassName.   

I propose changing it to GetNameOfClass in ITK to avoid an future problems.

-Bill