[Insight-users] FixedArray::operator[] definition for "unsigned __int64"

Bradley Lowekamp blowekamp at mail.nih.gov
Thu Jul 14 17:56:16 EDT 2011


Hello Ramon,

Which version of the Visual Studio compiler are you using?

It appears that you are relying on some type of implicit conversion. On may compilers this would produce a warning in some cases. It is best to make an explicit cast. My first guest would be to try the following, if you would like to to work on v3.20 and v4

fixedPoint[col] = y[ static_cast<size_t>( Mx*col+row )];

for just v4 you could also do:

fixedPoint[col] = y[ static_cast<itk::SizeValueType>( Mx*col+row )];

where itk::SizeValueType is defined in itkIntTypes.h, but should be indirectly included with just about any other itk header.


I am not entirely sure how to address you questions regarding ITKv4 support for __int64. ITK is a very large toolkit with templates for generic type, certainly as with v3.20 there are some places where this type can be used and some places where it can't. There was a change to better support 64-bit windows in ITKv4.


Hope this helps,

Brad

On Jul 14, 2011, at 11:21 AM, Ramón Casero Cañas wrote:

> 
> Hi,
> 
> In summary my question is whether ITK v4.0 supports __int64, and is 
> v3.20 going to get patched?
> 
> Full background to my question:
> 
> I have the following MEX C++ code:
> 
> <SNIPPET>
>    for (mwSize row=0; row < Mx; ++row) {
>      for (mwSize col=0; col < (mwSize)Dimension; ++col) {
>        fixedPoint[col] = y[Mx * col + row];
>      }
> </SNIPPET>
> 
> where mwSize (a Matlab MEX type) translates to size_t and
> fixedPoint is an itk::FixedPoint<float, 3>.
> 
> This codes compiles for linux 32 and 64 bit, and Windows 32 bit, but 
> throws a compilation error in Windows 64 bit.
> 
> <ERROR>
> 2>..\..\..\..\..\src\gerardus\clean\matlab\ItkToolbox
> \ItkPSTransform.cpp(359):
> error C2593: 'operator [' is ambiguous
> 2>          E:/devel/src/kitware/itk/Code/Common\itkFixedArray.h(207):
> could be 'double &itk::FixedArray<TValueType,VLength>::operator
> [](unsigned long)'
> 2>          with
> 2>          [
> 2>              TValueType=double,
> 2>              VLength=2
> 2>          ]
> 2>          E:/devel/src/kitware/itk/Code/Common\itkFixedArray.h(205):
> or       'double &itk::FixedArray<TValueType,VLength>::operator
> [](long)'
> 2>          with
> 2>          [
> 2>              TValueType=double,
> 2>              VLength=2
> 2>          ]
> 2>          E:/devel/src/kitware/itk/Code/Common\itkFixedArray.h(203):
> or       'double &itk::FixedArray<TValueType,VLength>::operator
> [](unsigned int)'
> 
> ...
> </ERROR>
> 
> The reason is that for Windows 64 bit, Visual Studio seems to convert 
> mwSize to "unsigned __int64", that is not an ANSI type.
> 
> Because I'm using ITK 3.20, InsightToolkit/Common/itkFixedArray.h 
> defines the following
> 
> <SNIPPET>
>    /** Allow the FixedArray to be indexed normally.  No bounds checking
> is done.
>     * The separate versions are a work-around for an integer conversion
> bug in
>     * Visual C++. */
>          reference operator[](short index)                { return
> m_InternalArray[index]; }
>    const_reference operator[](short index) const          { return
> m_InternalArray[index]; }
>          reference operator[](unsigned short index)       { return
> m_InternalArray[index]; }
>    const_reference operator[](unsigned short index) const { return
> m_InternalArray[index]; }
>          reference operator[](int index)                  { return
> m_InternalArray[index]; }
>    const_reference operator[](int index) const            { return
> m_InternalArray[index]; }
>          reference operator[](unsigned int index)         { return
> m_InternalArray[index]; }
>    const_reference operator[](unsigned int index) const   { return
> m_InternalArray[index]; }
>          reference operator[](long index)                 { return
> m_InternalArray[index]; }
>    const_reference operator[](long index) const           { return
> m_InternalArray[index]; }
>          reference operator[](unsigned long index)        { return
> m_InternalArray[index]; }
>    const_reference operator[](unsigned long index) const  { return
> m_InternalArray[index]; }
> </SNIPPET>
> 
> 
> but it's not able to deal with a
> 
> FixedArray::operator[](unsigned __int64)
> 
> 
> I have seen that in ITK 4.0.0 there are new definitions for 
> FixedArray::operator[]
> 
> http://www.itk.org/Doxygen/html/itkFixedArray_8h_source.html
> 
> <SNIPPET>
> reference operator[](long long index)                 { return 
> m_InternalArray[index]; }
> const_reference operator[](long long index) const { return 
> m_InternalArray[index]; }
> reference operator[](unsigned long long index)        { return 
> m_InternalArray[index]; }
> const_reference operator[](unsigned long long index) const { return 
> m_InternalArray[index]; }
> </SNIPPET>
> 
> 
> 
> Does v4.0 support __int64, and is v3.20 going to get patched?
> 
> 
> Best regards,
> 
> Ramon.
> 
> -- 
> Dr. Ramón Casero Cañas
> 
> Computational Biology
> Department of Computer Science
> University of Oxford
> Wolfson Building, Parks Rd
> Oxford OX1 3QD
> 
> tlf     +44 (0) 1865 610737
> web     http://web.comlab.ox.ac.uk/people/Ramon.CaseroCanas
> photos  http://www.flickr.com/photos/rcasero/
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users

========================================================
Bradley Lowekamp  
Lockheed Martin Contractor for
Office of High Performance Computing and Communications
National Library of Medicine 
blowekamp at mail.nih.gov


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110714/948e79c3/attachment.htm>


More information about the Insight-users mailing list