[Insight-users] Any known template depth limitations with GCC 3.2?

Luis Ibanez luis.ibanez@kitware.com
Sat, 12 Apr 2003 00:37:41 -0400


Hi Parag,

It is very likely that the problem is caused by the definition
of "InputImageDimension" in your class ContourIntersectionFilter.

There is some magic involved in forcing the compiler to evaluate
the enums or the static const that we use for carrying on the
values of ints as template parameters.

You may want to try the macros (from itkMacro.h):

    itkStaticConstMacro()
    itkGetStaticConstMacro()

and in ImageBase look at the helper class

     ExtractImageDimension.



What usually happens in practice is that the compiler evaluates
the numerical value of template argument in some cases, and not
in other cases. So, it may be happening that in the compilation
of the header file your InputImageDimension is being evaluated
as =3, while in the .cxx compilation it is passing as =0.

The use of the aforementioned macros should help to force the
compiler to perform a consistent evaluation of the numeric
parameters.

BTW this is very compiler-dependent... that's why the macros
implementations are plenty of #ifdefs.



Regards


  Luis


-----------------------------
Parag Chandra wrote:
> Hi,
>  
> I've derived a class from itkProcessObject that compiles just fine under 
> MS VisualC++ 6. However, I'm getting a strange error from GCC on RedHat 
> 8.0 that claims the prototype for a method I've defined in my .txx file 
> does not match the declaration in my .h file, even though the two are 
> identical according to the compiler:
>  
> /mnt/development/aks/Code/Processing/aksContourIntersectionFilter.cxx:68: 
> protot
> ype
>    for `TInputImage::PixelType
>    
> aks::ContourIntersectionFilter<TInputImage>::DetermineCrossedContour(const
>    itk::ContinuousIndex<aks::ImageToPointSetFilter<TInputImage,
>    aks::PointsOfInterestSet<double, 2, 5, aks::POIMeshTraits<double, 2, 
> 5, 2,
>    double, double, double> > >::OutputPointSetType::PointType::CoordRepType,
>    aks::ContourIntersectionFilter<TInputImage>::InputImageDimension>&)' does
>    not match any in class `aks::ContourIntersectionFilter<TInputImage>'
> /mnt/development/aks/Code/Processing/aksContourIntersectionFilter.h:107: 
> candida
> te
>     is: TInputImage::PixelType
>    
> aks::ContourIntersectionFilter<TInputImage>::DetermineCrossedContour(const
>    itk::ContinuousIndex<aks::ImageToPointSetFilter<TInputImage,
>    aks::PointsOfInterestSet<double, 2, 5, aks::POIMeshTraits<double, 2, 
> 5, 2,
>    double, double, double> > >::OutputPointSetType::PointType::CoordRepType,
>    aks::ContourIntersectionFilter<TInputImage>::InputImageDimension>&)
> I cut and pasted the candidate and the prototype as reported above, and 
> they are identical. In my code, they appear as:
>  
> InputImagePixelType DetermineCrossedContour(const ContinuousIndexType 
> &index);
>  
> in the header, and as:
>  
> template <class TInputImage>
> typename ContourIntersectionFilter<TInputImage>::InputImagePixelType
> ContourIntersectionFilter<TInputImage>
> ::DetermineCrossedContour(const ContinuousIndexType &index)
> in the source, where InputImagePixelType and ContinuousIndexType are 
> defined as follows:
>  
>     typedef typename itk::ContinuousIndex<OutputCoordRepType, 
> InputImageDimension>
>         ContinuousIndexType;
>     typedef typename InputImageType::PixelType InputImagePixelType;
> If I simply change the definition of ContinuousIndexType to:
>  
>     typedef typename itk::ContinuousIndex<double, 2> ContinuousIndexType;
>  
> then the code compiles fine with GCC. Does anyone know what might be 
> causing this? It seems like I'm running up against some ceiling on 
> template depth.
>  
> Thanks.
>  
> -Parag Chandra
>