[freetds] [PATCH] for win32 support of snprintf call in src/ctlib/ct.c

James K. Lowden jklowden at freetds.org
Mon Feb 8 23:07:45 EST 2010

David Dick wrote:
> +#ifdef WIN32
> +					*outlen= _snprintf(
> +#else
> +					*outlen= snprintf(
> +#endif

Thank you for the patch, but we have to turn it down!  Cf.
include/tds_sysdep_private.h for a better way:

#ifdef __MSVCRT__
#define getpid()           _getpid()
#define strdup(s)          _strdup(s)
#define stricmp(s1,s2)     _stricmp(s1,s2)
#define strnicmp(s1,s2,n)  _strnicmp(s1,s2,n)

The test is for using Microsoft's compiler, not Win32, because we're
actually interested in something slightly different: which C Standard
library is being used.  

Your patch assumes any Win32 compilation uses Microsoft's library, which
wouldn't be the case with MinGW, for instance.  The above test assumes --
rather more safely -- that anyone compiling with Microsoft's compiler is
using their C runtime.  (While it's possible to use another
implementation, it's surely rarely done.) 


More information about the FreeTDS mailing list