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

Kent Williams kent at psychiatry.uiowa.edu
Wed Apr 5 11:02:44 EDT 2006


Solution #1 follows the rules of header parsimony:
1. Attempt to only #include headers that are actually relevant to the 
current source. Maximalist includes slow down compiles, and make 
tracking down inter-header problems a pain.

2. If a header is #included, it should have the same behavior regardless 
of context.  The fact that different traits are defined depending on 
whether itkNumericTraitsRGB.h is included is a bad thing.

3. If a header depends on another header, it should include it. This 
conspires against rule #1, but in ITK, each headers includes a 
conditional bracket:

#ifndef __itkCLASSNAME_h
#define __itkCLASSNAME_h
#endif

So you can optimize out duplicate includes thusly:

#ifndef __itkCLASSNAME_h
#include <itkCLASSNAME.h>
#endif

Zachary Pincus wrote:

> (1) Make the above headers #include the correct numeric traits.
> (2) Make the master NumericTraits header #include all subsidiary  
> headers. (Brad didn't really like this, but I list it for completeness.)
> (3) By convention, every time a user uses a compound pixel type, they  
> will have to remember to also #include the correct NumericTraits, in  
> case any of the filters they will use need such traits.
>
> Right now the de facto "solution" is 3. I think 1 or 2 is better, and  
> it seems that Brad thinks 1 is the way to go.
>
> Should I go ahead and add fix (1) to the ITK CVS?
>
> Zach
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
>



More information about the Insight-developers mailing list