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

Ramón Casero Cañas rcasero at gmail.com
Thu Jul 14 11:21:52 EDT 2011


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/


More information about the Insight-users mailing list