[IGSTK-Users] snprintf versus _snprintf

David Gobbi dgobbi at atamai.com
Wed Sep 20 16:30:37 EDT 2006


Hi Steve,

Adding a cmake check wouldn't fix the main issue, which is that 
sprintf-style formatting doesn't really belong in IGSTK at all.  I even 
have it listed in the bug tracker.

Originally my tracking code used sprintf (before the code became part of 
IGSTK) and then I switched over to snprintf to avoid warnings under 
Visual Studio 2005.

My intent is to replace the snprintf calls with calls to a safer 
conversion routine that produces a C++ string instead of writing to a 
char array.

As an intermediate fix, though, please try adding an #ifdef for cygwin, 
and if it fixes your problem, I will commit it to cvs.

Thanks,

 - David



Steve Robbins wrote:
> Hi,
>
> I'm building IGSTK using cygwin on WindowsXP.
>
> It doesn't compile out-of-the-box, due to this bit of code in 
> Source/igstkNDICommandInterpreter.cxx:
>
> // On MSVC and Borland, snprintf is not defined but _snprintf is.
> // This should probably be checked by CMake instead of here.
> #if defined(WIN32) || defined(_WIN32)
> #ifndef snprintf
> #define snprintf _snprintf
> #endif
> #endif
>
>
> It's not a good assumption that WIN32 systems have _snprintf() but not 
> snprintf().  Cygwin has the latter but not the former.
>
> As the comment says, this should be checked by CMake.  Moreover, it 
> ought to actually check for the presence of snprintf() rather than 
> relying on a complicated "#if" conditional using compiler and OS 
> symbols...
>
> Sorry, but I've only got time for this rant and not a patch ;-)
>
> -Steve
>
> _______________________________________________
> IGSTK-Users mailing list
> IGSTK-Users at public.kitware.com
> http://public.kitware.com/cgi-bin/mailman/listinfo/igstk-users
>




More information about the IGSTK-Users mailing list