[freetds] Using freetds in Windows

Christos Zoulas christos at zoulas.com
Mon Jan 11 23:05:51 EST 2010

On Jan 11,  9:56pm, jklowden at freetds.org ("James K. Lowden") wrote:
-- Subject: Re: [freetds] Using freetds in Windows

| Christos Zoulas wrote:
| > I think Win32 strerror(3) is threadsafe. 
| > 
| > Even when doing i18n? 
| AFAIK.  I don't see any technical reason why not.  

Well, to be thread-safe it needs to use per-thread local storage
for the returned string since it cannot know what the string will
contain. It is easier to punt and do the simple:

char *
strerror(int num)
        static char buf[NL_TEXTMAX];
        int error = strerror_r(num, buf, sizeof(buf));
        if (error)
                errno = error;
        return buf;

This is why one should be using strerror_r() if it exists, or protect
strerror() with a mutex if it does not.


More information about the FreeTDS mailing list