[IGSTK-Users] snprintf versus _snprintf

David Gobbi dgobbi at atamai.com
Thu Sep 21 13:52:30 EDT 2006


Steve Robbins wrote:
> Quoting David Gobbi <dgobbi at atamai.com>:
>
>> Regarding itksys::SystemTools, did you have any specific problems with
>> compilation?  The code here looks fine to me: the "Sleep" function is a
>> Win32 method, and it is just as valid under cygwin as it is under any
>> other compiler on the Win32 platform.  An "#ifdef _WIN32" seems
>> appropriate here.  Am I missing something?  The problem with
>> igstkTransformTest.cxx was that it wasn't including the windows.h
>> header file.
>
> Correct; and RobotCommunication.cxx had the same problem: it wasn't 
> including windows.h.
>
> However, my feeling is that rather than duplicate that include 
> (conditional on #if WIN32) and the Sleep()/usleep() code (conditional 
> on #if WIN32) in every C++ class that wants to sleep, it is much 
> cleaner to #include <itksys/SystemTools> and use Delay().

Oh, that's what you meant.  Sorry, I misunderstood, I thought you wanted 
to change the SystemTools code!


> NeedleBiopsy.h provides another example of the same antipattern.  The 
> code
>
>
> #ifdef WIN32
> #include "igstkSerialCommunicationForWindows.h"
> #else
> #include "igstkSerialCommunicationForPosix.h"
> #endif
>
> ...
>
>   /** typedefs for the communication */
> #ifdef WIN32
>   typedef SerialCommunicationForWindows                 
> CommunicationType;
> #else
>   typedef SerialCommunicationForPosix                   
> CommunicationType;
> #endif
>
>
> will have to be repeated in *every* class that wants to use serial 
> communications.  It could easily be hidden inside the 
> igstkSerialCommunication.h header.  One could imagine a factory method 
> to construct the correct igstkSerialCommunication subclass.

There is an overlying rule for IGSTK, though, that all instantiations 
must be explicit, no factories are allowed.  We have considered rolling 
the two SerialCommunication classes together into one class that works 
on both platforms.

 - David






More information about the IGSTK-Users mailing list