[Insight-users] Re: a compiling error about CurvatureAnisotropicDiffusionImageFilter

Luis Ibanez luis . ibanez at kitware . com
Mon, 26 Aug 2002 12:14:23 -0400


Hi Zhao,

This error is the result of a bad usage of namespaces.

You probably have a statement like:

    "   using namespace std; "

somewhere in your code, before including the itk files.

This opens the "std" namespace and eliminates all the
possible advantages that namespaces can provide.
The statement allows your compiler to try to match
any appearance of "list" as if it were "std::list".

Curiously, the compiler goes pretty far...

The line where you are getting the compiler error is:

itkFiniteDifferenceImageFilter.txx line 157:

::ResolveTimeStep(const TimeStepType *list, const bool *valid, int size)

Where the variable name of the first parameter is "list".

VC++ is trying to interpret this "list" as the class "std::list"
and complains because it is lacking the template parameters that
a normal std::list should have (e.g. std::list<double> ).

Here is what VC++ says:

d:\insightbeta2\code\common\itkfinitedifferenceimagefilter.txx(157) :
error C2955: 'list' : use of class template requires template argument list
c:\program files\microsoft visual studio\vc98\include\list(415) : see
declaration of 'list'



Please check all your project and remove any appearance of
"using namespace std;". Such statement should never be used in
a header file. This is just a shorcut for avoiding to type
"std::" preceding the classes of this namespace.  The right
thing to do is to fully specify the namespace for the classes
as it is done with "itk::"  (even if that means a few more
keystrokes...).

Like:

   std::cout << "message" << std::endl;
   std::vector< float > vf;
   itk::Image<float,2>::Pointer image;
   std::list< int > intList;


Let us know if you encounter any problems,

Thanks


  Luis


==============================================================

zhao wrote:
> Hi all,
> 	This compiling error is caused by a improper order of header files. e.g.:
> 
> If the headers files are arranged in such an order, the project is compiled smoothly.
> 
> #include "itkCurvatureAnisotropicDiffusionImageFilter.h"
> #include "itkGradientMagnitudeImageFilter.h"
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkRawImageIO.h"
> #include "itkImageRegionIterator.h"
> 
> If the first header file are move to the bottom (as below), there will be the compiling error.
> 
> #include "itkGradientMagnitudeImageFilter.h"
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkRawImageIO.h"
> #include "itkImageRegionIterator.h"
> #include "itkCurvatureAnisotropicDiffusionImageFilter.h"
> 
> I dont' know why, though the problem is solved.
> 
> 
>>Hi all,
>>
>>	This sentence below cause a compiling error (under MSVC6, I know the error is caused by this sentence because the error appears with this sentence):
>>
>>		typedef itk::Image<float, ImageDimension> FloatImageType;
>>
>>	  	itk::CurvatureAnisotropicDiffusionImageFilter<FloatImageType, FloatImageType>::Pointer   diffusion = itk::CurvatureAnisotropicDiffusionImageFilter<FloatImageType,FloatImageType>::New();
>>
>>
>>------------------compiling error------------------
>>
>>		d:\insightbeta2\code\common\itkfinitedifferenceimagefilter.txx(157) : error C2955: 'list' : use of class template requires template argument list
>>       c:\program files\microsoft visual studio\vc98\include\list(415) : see declaration of 'list'
>>       d:\insightbeta2\code\common\itksmartpointer.h(59) : while compiling class-template member function 'double __thiscall itk::FiniteDifferenceImageFilter<class itk::Image<float,2>,class itk::Image<float,2> >::Re
>>solveTimeStep(const double *,const bool *,int)'
>>Error executing cl.exe.
>>
>>       I can't find why this is the case. Need your help, thanks!
>>
>>
>>Zhao ChenGuang
>>P.O.Box:010,
>>Dept. BME,
>>Shanghai Jiao Tong University,
>>1954# Hua Shan Road,
>>Shanghai,P.R.China,
>>200030
>>
>>
>>
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>