[Insight-developers] Re: [Insight-users] ITK compatablility with 64-bit Windows or Linux?

Simon Warfield warfield at bwh.harvard.edu
Tue Mar 15 00:16:33 EST 2005


Robert Maroon wrote:

>Hi everyone,
>
>I want to recompile some of my ITK code onto a 64-bit
>platform, but first I was wondering if there are any
>issues compiling or running ITK programs on 64-bit
>Windows or Linux platforms? 
>  
>

ITK can run on a 64 bit platform, such as x86_64. 
My experience is with red hat enterprise linux on Intel Xeon CPUs, and 
with Solaris 10 on AMD Opteron CPUs.
The bottom line is it basically works fine.


Some things to note:
1. cmake 2.0.5 does not understand the x86_64 platform, and will select 
the wrong version of X11 libraries, wrong version of OpenGL and wrong 
version of tcl/tk.
You can manually correct these - on rhel, these are in /usr/X11R6/lib64 
and /usr/lib64

2. fltk - has some casts between integers and pointers that look wrong 
to me.  This might lead to difficulties in some of the InsightApplications.

3.
ITK has some problems due to templates definitions that lead to attempts 
to cast the integer 0 to a pointer of a different size on x86_64.
e.g. itkSmartPointer.h has a template 
definition:                                                                               


template <typename R>
bool operator != ( R r ) const
{ return (m_Pointer != (ObjectType*)(r) ); }

This cast is not really safe, and gives warning messages such as:

> Building object file itkBSplineResampleImageFunctionTest.o...
> /opt/x86_64/src/InsightToolkit-2.0.0/Code/Common/itkSmartPointer.h: In
>    member function `bool itk::SmartPointer<TObjectType>::operator!=(R) 
> const
>    [with R = int, TObjectType = const itk::Image<PixelType, 2>]':
> /opt/x86_64/src/InsightToolkit-2.0.0/Code/BasicFilters/itkBSplineResampleImageFunction.h:73:   
> instantiated from `void itk::BSplineResampleImageFunction<TImageType, 
> TCoordRep>::SetInputImage(const TImageType*) [with TImageType = 
> itkBSplineResampleImageFunctionTest(int, char**)::ImageType, TCoordRep 
> = double]'
> /opt/x86_64/src/InsightToolkit-2.0.0/Testing/Code/BasicFilters/itkBSplineResampleImageFunctionTest.cxx:78:   
> instantiated from here 
> /opt/x86_64/src/InsightToolkit-2.0.0/Code/Common/itkSmartPointer.h:90: 
> warning: cast
>    to pointer from integer of different size

The problem is there are several places constructs like:
    if ( this->m_Coefficients != 0 )
are used.  This calls the != operator for the smart pointer template, 
which is not required to interpret 0 as a NULL pointer in this context.
The cast in the operator definition then tries to interpret the integer 
0 as a pointer, and complains since they are not the same size.

A stricter template operator definition would replace the cast above 
with this:
  { return (m_Pointer != static_cast<ObjectType *>(r) ); }

This then leads to errors being declared where the usage is incorrect, e.g.

> /opt/x86_64/src/InsightToolkit-2.0.0/Code/Common/itkSmartPointer.h: In
>    member function `bool itk::SmartPointer<TObjectType>::operator!=(R) 
> const
>    [with R = int, TObjectType = const itk::Image<PixelType, 2>]':
> /opt/x86_64/src/InsightToolkit-2.0.0/Code/BasicFilters/itkBSplineResampleImageFunction.h:73:   
> instantiated from `void itk::BSplineResampleImageFunction<TImageType, 
> TCoordRep>::SetInputImage(const TImageType*) [with TImageType = 
> itkBSplineDecompositionImageFilterTest(int, char**)::ImageType, 
> TCoordRep = double]'
> /opt/x86_64/src/InsightToolkit-2.0.0/Testing/Code/BasicFilters/itkBSplineDecompositionImageFilterTest.cxx:86:   
> instantiated from here
> /opt/x86_64/src/InsightToolkit-2.0.0/Code/Common/itkSmartPointer.h:91: 
> invalid
>    static_cast from type `int' to type `const itk::Image<PixelType, 2>*'
> make[7]: *** [itkBSplineDecompositionImageFilterTest.o] Error 1


The usage can be corrected by using constructs like:
  if (this->m_Coefficients)


I have been wondering if it would be easier to modify the operator 
definition to interpret its argument as a pointer, or to change all 
comparisons throughout ITK of the form:
if (pointer != 0)
  to
if(pointer)




>Thanks,
>
>Robert
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>  
>


-- 
Simon K. Warfield, Ph.D. warfield at bwh.harvard.edu Phone:617-732-7090




More information about the Insight-developers mailing list