[Insight-users] How to use code from WatershedSegmentation1

Luis Ibanez luis . ibanez at kitware . com
Sun, 23 Nov 2003 17:31:40 -0500


Hi Wicheng,

The variable name "list" shouldn't conflict with the "list"
type defined in VC++, since this last one is in the namespace
"std".

I wonder if you are opening the namespace std by using a
statement like the following:

                  using namespace std;

Please search into your code to see if you have such a line.

If you find it, remove it immediately and make sure that you
never use it again.  Opening the namespaces defeats the whole
purpose of namespaces which is to avoid conflicts like the one
you are facing.

Some people open the namespaces in other to be able to write
the lazy line

              cout << "I'm lazy";

instead of the correct line

              std::cout << "I'm using VIM";

a good editor like "Vim" will help a lot in making easy to
use the correct namespace notation.

Also make sure that replace any potential header include
like

          #include <list.h>

with

          #include <list>

The second one will use the modern implementation of STL.
(this is a VC++ 'feature').




Please let us know what you find.


Thanks


     Luis



--------------------------------------

SHEN, WEICHENG . wrote:
> Greetings, 
> 
> I have a little test program called cvision (which was created using MS
> Visiual Studio 6 with MFC option). Inside that project, I attempt to use the
> itk code from example WatershedSegmentation1. Here is what I did. 
> 
> 1. Test the WatershedSegmentation1 by "rebuilding" it using MS Visual Studio
> 6. It works fine, and it indicates that the ITK is working appropriately.
> 
> 2. Inside my project cvision, I copied the code of WatershedSegmentation1
> into a function, and modified the appropriate C/C++ compiler and linker
> options. 
> 
> 3. "Rebuild" the cvision project, and the following message occurs when
> compiling the line "DiffusionFilterType::Pointer diffusion =
> DiffusionFilterType::New();"
> 
> 
> 
> 
> ======================================================================== 
> Deleting intermediate files and output files for project 'cvision - Win32
> Debug'. 
> --------------------Configuration: cvision - Win32 Debug--------------------
> 
> Compiling resources... 
> Compiling... 
> StdAfx.cpp 
> Compiling... 
> cvapp.cpp 
> c:\projects\insighttoolkit-1.2.0\code\common\itkfinitedifferenceimagefilter.
> txx(158) : 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' 
>         c:\projects\insighttoolkit-1.2.0\code\common\itksmartpointer.h(59) :
> while compiling class-template member function 'double __thiscall
> itk::FiniteDifferenceImageFilter<class itk::Image<class
> itk::Vector<float,3>,2>,class itk::Image<class itk
> 
> ::Vector<float,3>,2> >::ResolveTimeStep(const double *,const bool *,int)' 
> cvision.cpp 
> cvisionDlg.cpp 
> Generating Code... 
> Error executing cl.exe. 
> 
> cvision.exe - 1 error(s), 0 warning(s) 
> ======================================================================= 
> 
> My initial guess is that somehow the compiler is confused the variable list
> in "itkfinitedifferenceimagefilter.txx" with the list of C++. Any
> suggestions that I shall do to resolve this? Thanks a lot!
> 
> 
> 
> Weicheng 
> 
>   
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>