Hi Brad,<br><br> You have said it all ! :-)<br><br><br>As usual... what it seemed to be a localized changed<br>turned out to be a massive refactoring.<br><br>We have promiscuously used "long", and "unsigned long"<br>
all over the place, instead of having had the precaution of<br>declaring a Trait for the components of Size, Index and <br>Offset. (now we have IndexValueType, SizeValueType,<br>and OffsetValueType).<br><br><br>The same goes for Spacing and Origin, but that's a bit<br>
of a separate issue.<br><br><br>As you pointed out, we will have to search-and-destroy<br>all explicit uses of "long" and "unsigned long" that refer<br>to Index, Size and Offset components.<br><br><br>
I believe that the changes applied during the weekend are<br>good for covering Linux in 32 and 64 bits, but unfortunately<br>they are still not enough for covering Windows 64 bits,<br>where <br><br><br> size_t and ptrdiff_t have different size than "long".<br>
<br><br>Banning the use of "long" will come easy by simply keeping<br>a couple of Windows 64 bits Nightly builds, (once we <br>replace size_t and ptrdiff_t as the component types of <br>Size, Index and Offset.)<br>
<br>In the meantime, unfortunately we will have to go down<br>the painstaking process of cleaning class by class.<br><br><br>The process is not hard, <br>but it promises to be very long:<br><br>It comes down to getting a Visual Studio Windows 64 bits<br>
build to run green, after we replace the new types.<br><br><br>It will be great to get this done by the Release of ITK 3.16,<br>but that may absorb too much of our resources.<br><br><br>I'll keep working on this as a background task...<br>
<br><br> Luis<br><br><br>---------------------------<br><div class="gmail_quote">On Mon, Jul 13, 2009 at 11:30 AM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="">Luis,<div><br></div><div><span style="white-space: pre;">        </span>This looks like an absolutely massive effort you are attempting here. I have grepped through the iterator classes are there alot of incorrect usages of long:</div>
<div> </div><div>itkImageRegionReverseConstIterator.h: m_SpanEndOffset = this->m_BeginOffset - static_cast<long>(this->m_Region.GetSize()[0]);</div><div><br></div><div>And then there are complex relations like this:</div>
<div><br></div><div><div>itkSize.h: typedef unsigned long SizeValueType;</div><div><div>itkImageRegion.h: typedef Size< itkGetStaticConstMacro( ImageDimension ) > SizeType;</div><div>itkImageRegion.h: typedef typename SizeType::SizeValueType SizeValueType;</div>
<div>itkImageRegion.h: SizeValueType GetNumberOfPixels() const;</div><div><br></div><div><br></div><div>I am not really sure how all these issues can be tracked down. From the user list:</div><div><br></div><div><br></div>
<div><div class="im"><div>On Jul 10, 2009, at 12:46 PM, Michael Jackson wrote:</div><br><blockquote type="cite"><span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br>
IMNSHO, ITK (and VTK by extension) should absolutely BAN the use of<br>"long" in their projects. Period. Too many avoidable bugs come up from<br>its use. If you want a 32 bit integer use int or the standard ansi int<br>
type, if you want a 64 bit integer then use "long long int" or the<br>standard ansi 64 bit integer type.<br> "long int" is just a mess waiting to happen. Maybe a rule should be<br>put into the KWStyle project to look for and flag the use of 'long'?</span></blockquote>
<div><br></div><div><br></div></div><div>Do we need to go as far as banning the use of long and unsigned long? </div><div><br></div><div><br></div><div>Good Luck Luis,</div><div>Brad</div></div><div><br></div></div><div><br>
</div></div><div><br></div><div><div><div><div></div><div class="h5"><div>On Jul 10, 2009, at 6:33 PM, Luis Ibanez wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div class="h5">On recent realization: <br>
<br> "size_t" is unsigned :-/<br><br>and we need the OffsetValueType to be signed,<br>since we use it to compute differences...<br><br>It seems that what we need is the type<br> <br> "ptrdiff_t"<br>
<br>which is supposed to represent the differences<br>between two pointers, and therefore should be<br>capable of measuring distances between any<br>two locations in memory.<br> <br>I'm now rerunning the Experimental with <br>
"ptrdiff_t" instead of "size_t".<br><font color="#888888"><br><br> Luis<br></font><br>------------------------------------------------------------------------------------------------------<br> <div class="gmail_quote">
On Fri, Jul 10, 2009 at 12:30 PM, Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Kana,<br><br>Thanks a lot for looking into this and sharing your findings.<br><br>I just confirmed that in Windows 64bits, the "long" type is<br>only 4 bytes.<br><br>Here is the program I used:<br><br>#include <iostream><br>
#include "itkOffset.h"<br>#include "itkNumericTraits.h"<div><br><br>int main()<br>{<br> unsigned long tt;<br> std::cout << "size = " << sizeof(tt) << std::endl;<br> tt = -1;<br>
std::cout << "tt = " << tt << std::endl;<br><br></div> typedef itk::Offset<3> OffsetType;<br> typedef OffsetType::OffsetValueType OffsetValueType;<br><br> OffsetValueType offsetValue;<br>
<br> std::cout << "sizeof(offsetValue) = " << sizeof( offsetValue ) << std::endl;<br><br> offsetValue = itk::NumericTraits< OffsetValueType >::max();<br><br> std::cout << "OffsetValueType max() = " << offsetValue << std::endl;<br>
<br> return EXIT_SUCCESS;<br>}<br><br><br>with this CMakeLists.txt file<br><br><br>CMAKE_MINIMUM_REQUIRED(VERSION 2.4)<br>IF(COMMAND CMAKE_POLICY)<br> CMAKE_POLICY(SET CMP0003 NEW)<br>ENDIF(COMMAND CMAKE_POLICY)<br><br>
<br>PROJECT(64bitsTest)<br><br>FIND_PACKAGE(ITK REQUIRED)<br>INCLUDE(${ITK_USE_FILE})<br><br>ADD_EXECUTABLE(typesTest typesTest.cxx )<br><br>TARGET_LINK_LIBRARIES(typesTest ITKCommon)<br><br></blockquote></div><br> </div>
</div><span><ATT00001.txt></span></blockquote></div><br><div> <span style="font-size: 12px;"><div style=""><span style="border-collapse: separate; border-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><p style="margin: 0px;">
<font style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal;" size="3" face="Helvetica">========================================================</font></p>
<p style="margin: 0px;"><font style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal;" size="3" face="Helvetica">Bradley Lowekamp<span> </span><span> </span></font></p>
<p style="margin: 0px;"><font face="Arial"><span style="font-family: Arial;"><span style="font-family: Arial;">Lockheed Martin </span></span></font><font style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal;" size="3" face="Helvetica">Contractor for</font></p>
<p style="margin: 0px;"><font style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal;" size="3" face="Helvetica">Office of High Performance Computing and Communications</font></p>
<p style="margin: 0px;"><font style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal;" size="3" face="Helvetica">National Library of Medicine<span> </span></font></p>
<p style="margin: 0px;"><font style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal;" size="3" face="Helvetica"><a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a></font></p>
<br></span></div></span> </div><br></div></div></blockquote></div><br>