[Insight-developers] int types questions

M Stauffer (V) mstauff at verizon.net
Thu Oct 27 12:32:32 EDT 2011


Hi,

Matt and I have been discussing what type to use for the number of
dimensions. Here at PICSL we've recently been pushing to use named types
in our code instead of basic types, per instruction from Luis. We've
been using itk::SizeValueType (itkIntTypes.h) in many places for
anything that's counted, including # of dimensions.

Matt's pointed out that the definition of SizeValueType in itkIntTypes.h
(code copied below) could result in a 64-bit type on 32-bit systems
depending on the cmake settings, although I think it's the opposite -
setting ITK_USE_64BITS_IDS to OFF would create 32-bit type (unsigned
long) on 64-bit systems, and otherwise if ON, would only yield 64-bit
type on a 64-bit system.

Questions:

1) The #if block below looks to be recognizing 32-bit and 64-bit
systems. The ITK_USE_64BITS_IDS CMake option says "When ON, ITK will use
64 bits integers to index pixels. This is needed for managing images
larger than 4Gb in some platforms." However, it seems like what it also
does is allow defining 32-bit indexing typedefs on 64-bit systems. That
doesn't seem right. Also, it effects more than just image indexing since
SizeValueType and IdentifierType are also defined.

2) What type should the # of dimensions be? Do we create a particular
typedef for it to standardize it with a named type? Or should
SizeValueType be appropriate? Matt's suggesting always using 'unsigned
int' for the number of dimensions.

3) In the code below for the 32-bit block, is 'long' meant to guarantee
32-bit length? 'int', strictly speaking, is guaranteed to be at least
16-bit, and 'long' to be at least 32-bit, although not restricted to
that (http://c-faq.com/decl/inttypes.html). In practice they're
generally both 32-bit, but can that be relied on for all the systems itk
supports? If we want to be sure that it's 32-bit on a 32-bit system,
should we use uint32_t and int32_t below instead of 'unsigned long' and
'long'? Or should we use 'size_t' instead?



More information about the Insight-developers mailing list