MantisBT - ITK
View Issue Details
0009426ITKpublic2009-08-15 04:102010-10-21 12:31
Gaetan Lehmann 
Bradley Lowekamp 
normalminorhave not tried
closedfixed 
 
ITK-3-18 
0009426: ITK_UINT64 and vxl_uint_64 are not a 64bit integer on windows
in itkIntType.h we have:

 #ifdef _WIN32
   typedef long ITK_INT64;
 #endif

 #ifdef _WIN32
   typedef unsigned long ITK_UINT64;
 #endif

and vxl_uint_64 is defined as void on vc60.
As a consequence, there is no portable 64bit integer type usable in ITK.
No tags attached.
parent of 0010093closed Mathieu Malaterre Changes in "itkIntTypes.h" conflict with "gdcmCommon.h" 
related to 0001538closed Luis Ibanez itkIntTypes.h and 64 bits integer type 
? itkIntTypes.h (4,640) 2009-12-14 12:13
https://public.kitware.com/Bug/file/2720/itkIntTypes.h
Issue History
2009-08-15 04:10Gaetan LehmannNew Issue
2009-08-15 12:20Luis IbanezNote Added: 0017136
2009-08-19 09:45Tom VercauterenNote Added: 0017160
2009-10-22 12:04Bradley LowekampNote Added: 0018191
2009-10-22 12:04Bradley LowekampStatusnew => assigned
2009-10-22 12:04Bradley LowekampAssigned To => Bradley Lowekamp
2009-12-04 11:24Bradley LowekampRelationship addedrelated to 0001538
2009-12-11 11:47Bradley LowekampFile Added: itkIntTypes.h
2009-12-11 11:50Bradley LowekampFile Deleted: itkIntTypes.h
2009-12-11 11:50Bradley LowekampFile Added: itkIntTypes.h
2009-12-14 10:18Brad KingNote Added: 0018846
2009-12-14 12:13Bradley LowekampFile Deleted: itkIntTypes.h
2009-12-14 12:13Bradley LowekampFile Added: itkIntTypes.h
2009-12-15 09:25Bradley LowekampNote Added: 0018895
2009-12-15 09:30Brad KingNote Added: 0018896
2009-12-16 08:31Bradley LowekampNote Added: 0018914
2009-12-16 08:32Bradley LowekampNote Edited: 0018914
2009-12-16 08:32Bradley LowekampNote Edited: 0018914
2009-12-16 08:49Brad KingNote Added: 0018915
2010-01-15 09:38Bradley LowekampRelationship addedparent of 0010093
2010-06-22 15:19Bradley LowekampNote Added: 0021130
2010-06-22 15:19Bradley LowekampStatusassigned => resolved
2010-06-22 15:19Bradley LowekampFixed in Version => ITK-3-18
2010-06-22 15:19Bradley LowekampResolutionopen => fixed
2010-10-21 12:31Gabe HartStatusresolved => closed

Notes
(0017136)
Luis Ibanez   
2009-08-15 12:20   
Instead of the 64 bits types we should use size_t and ptrdiff_t, which will have the largest integer type that can be represented in that architecture.
(unsigned and signed respectively).
(0017160)
Tom Vercauteren   
2009-08-19 09:45   
I agree with Luis but in some cases, it is necessary to use integers of known size. For example when using sse functions. We could maybe rely on pstdint.h ( http://www.azillionmonkeys.com/qed/pstdint.h [^] ) for these cases.
(0018191)
Bradley Lowekamp   
2009-10-22 12:04   
I agree that in many cases size_t and ptrdiff_t should be used when initially one thinks they need an explicitly 64bit integer.

However, many times:
sizeof(long long) > sizeof( long )
and 32-bit build have 64 bit integers.


Also vxl_uint_64 is defined as void on vc60 because the 64-bit integer is incomplete on this system as it does not behave as expected in term of conversion etc...
(0018846)
Brad King   
2009-12-14 10:18   
The attached "itkIntTypes.h" looks pretty good. I have a couple comments:

- KWSYS_CAN_CONVERT_UI64_TO_DOUBLE should be itksys_CAN_CONVERT_UI64_TO_DOUBLE

- The line "typedef uintptr_t uintptr_t;" should be "typedef ::uintptr_t uintptr_t;"

Also, please create a test that verifies type size and signed-ness at runtime.

We should consider looking for <cstdint> and pulling types out of std:: if it is available. This could wait for later though.
(0018895)
Bradley Lowekamp   
2009-12-15 09:25   
Committed File:

http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/Common/itkIntTypes.h.diff?cvsroot=Insight&r1=1.7&r2=1.8 [^]


And Test:

http://public.kitware.com/cgi-bin/viewcvs.cgi/Testing/Code/Common/itkIntTypesTest.cxx?revision=1.4&root=Insight&view=markup [^]
(0018896)
Brad King   
2009-12-15 09:30   
Nice, thanks.
(0018914)
Bradley Lowekamp   
2009-12-16 08:31   
(edited on: 2009-12-16 08:32)
Baffling output of the failing test on VS6:

http://www.cdash.org/CDash/testDetails.php?test=38869515&build=494381 [^]

(0018915)
Brad King   
2009-12-16 08:49   
It's because of code like this in the test:

-------------------------------------
template <typename T>
bool CheckSize( size_t size )
{
  return ( sizeof( T ) == size );
}
-------------------------------------

VS6 only includes argument types in mangling and does not account for the template argument. Therefore the linker chooses one symbol for all the instantiations no matter the type. Change it to this:

-------------------------------------
template <typename T>
bool CheckSize( size_t size, T* = 0 )
{
  return ( sizeof( T ) == size );
}
-------------------------------------

Do the same for all the check functions.
(0021130)
Bradley Lowekamp   
2010-06-22 15:19   
update itkIntType includes new types which are tested to be of the correct size.