[freetds] Using freetds in Windows

James K. Lowden jklowden at freetds.org
Mon Jan 11 22:14:28 EST 2010

Frediano Ziglio wrote:
> Perhaps would be better to translate C
> errors into Windows system errors and use FormatMessage for windows and
> strerror for Unix?

Winsock errors cannot be formatted with FormatMessage.  That's why we have

> we always use strerror, windows or not. 

It matters more to you than to me.  :-)  

In the db-lib code we don't need to support multithreading.  I don't know
how to use errno portably in multithreaded code.  I would like to believe
that in any environment in which errno is in thread-local storage,
strerror(3) would be thread-safe.  

I encountered a bug today in replacements/strtok_r().  It doesn't treat
consecutive tokens as one, so at the end of the port 1434 response (two
semicolons), it returns a zero-length string instead of NULL.  It made me
wish we'd single-threaded the code instead of replacing it with something
that almost works.  

> I think that a developer
> have to use perl even on windows or manually copy file from distribution
> while users will use distribution which came with proper file.


> Why not adding .sln/.vcproj and Nmakefile to distribution ??

Laziness.  Good idea, though.  

> It's that macro is defined in replacements.h and tds_sysdep_private.h so
> I got a warning about redefinition. I build defncopy as cross compile
> using FreeTDS library (not MS one). 

Understood.  It's good you use Mingw and I use VS 2005.  If we get it to
compile both ways, we're doing something right.  



More information about the FreeTDS mailing list