[Insight-developers] Link errors and itk::NumericTraits on Windows

Brad King brad.king at kitware.com
Wed Apr 5 09:20:15 EDT 2006


Zachary Pincus wrote:
> There are three possible solutions that I can think of:
> (1) itkNumericTraits.h should #include all subsidiary NumericTraits  
> headers. Then generic filters can #include just one generic numeric  
> traits header, and be assured that regardless of what pixel types  they 
> are instantiated with, the right NumericTraits objects will be  available.
> (2) The NumericTraits class should declare that Zero and One are  
> ITKCommon_EXPORT. I don't know if this will break things.
> (3) Every class that might potentially be instantiated over RGB or  
> vector pixels, etc, should #include all possible NumericTraits headers.
> 
> I think option 1 sounds the best. Are there any other approaches?  Does 
> anyone have any ideas as to what to do here?

Putting ITKCommon_EXPORT on the instantiation of a template is the 
proper means to export it from a DLL with dllexport.  Putting it on the 
declaration does nothing on MSVC (though putting it on a full 
specialization should work just like any other class).  The problem is 
with *dllimport* for the code using the instantiation.  For methods a 
dllimport is not necessary, but for *data* it is necessary.  In the case 
of Zero and One trait data the ITKCommon_EXPORT must appear in the 
header where each trait specialization is defined.

Option #1 should not be necessary.  Classes using certain traits should 
include the headers for those traits (see below).

Option #2 is the correct choice as I explained above.

Option #3 should not be done.  Any instantiation using an RGB pixel type 
must have included the RGB pixel header, which should provide the 
NumericTraits specializations for RGB pixel types.

-Brad


More information about the Insight-developers mailing list