[Insight-users] 2GB VTK IO limit

Sean McBride sean at rogue-research.com
Thu Oct 9 18:44:24 EDT 2008


On 10/10/08 12:31 AM, Mathieu Malaterre said:

>Looking at the code I would think this is coming from piece such as:
>
>itkVTKImageIO.cxx:
>...
>ByteSwapper<short>::SwapRangeFromSystemToBigEndian((short *)buffer,
>static_cast<unsigned long>(this->GetImageSizeInComponents()) );
>...
>
>What is the size of an 'unsigned long' on macosx +gcc ? Anyway if VTK
>support larger file, this piece of code (and other cast) should be
>fixed.

The Mac OS ABI specifies that 'unsigned long' is 32bit when building as
32bit, and is 64bit when building as 64bit.  It is one of the (few)
basic types the changes size between ABIs.

In any case, 'unsigned long' is indeed the wrong type to use for things
like file length.  POSIX file APIs tend to use types like off_t.  On OS
X, off_t is 64bit on both the 32bit and 64bit ABIs.

Writing portable 32/64 bit-safe code is surprisingly non-trivial.  ITK
and VTK are riddled with such errors, as a cursory inspection reveals.

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada




More information about the Insight-users mailing list