[Insight-developers] ExceptionObject Borland Compile errors

Brad King brad.king at kitware.com
Wed May 28 11:09:00 EDT 2008


Niels Dekker wrote:
> Brad King wrote:
>> The itk SmartPointer is not designed for working with
>> incomplete types.
> 
> It works fine on GCC and MSVC, as I tested beforehand.  By the time 
> SmartPointer needs to access member functions of the type (in 
> itkExceptionObject.cxx), the complete type definitions are available. So 
> I think it's really a Borland issue.

Borland likes to instantiate some things too early.

>> I suggest making the smart pointer type point at a
>> LightObject (or other complete type used as a base class for the
>> internal data type) and then downcast inside the .cxx file.
> 
> Good suggestion...  Still things are even more tricky: when we would 
> declare ExceptionObject::m_ExceptionData as SmartPointer<LightObject>, 
> we would need to #include "itkLightObject.h" within 
> itkExceptionObject.h, right?  Unfortunately doing so would cause a lot 
> of compile errors, in unrelated CXX files that already do #include 
> "itkLightObject.h":
> 
> #include "itkLightObject.h" // error: LightObject undeclared identifier
> 
> It's because "itkLightObject.h" indirectly includes 
> "itkExceptionObject.h" (via "itkMacro.h") already!  You should really 
> try it yourself, because it's hard to explain.
> 
> So now I'm not entirely sure if LightObject can be used to do the 
> reference counting of ExceptionObject's data, because of this Borland 
> issue...  What do you think?

Instead of LightObject just write your own base class that provides the 
Register/UnRegister and counting stuff.  Make that a complete type in the 
header and then derive the real data type from it in the .cxx file.

-Brad


More information about the Insight-developers mailing list