cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Problems with compiling libcurl on Visual C++

From: Yang Tse <yangsita_at_gmail.com>
Date: Wed, 14 Feb 2007 03:33:52 +0100

On Tue, 13 Feb 2007, Robert (Bob) A. Monat wrote:

> From what I can tell, if you create threads according to the way
> Microsoft recommends, then each thread has its own memory and there is
> no need for the _r (e.g. gmtime_r) version of routines. I was not able
> to find a reference to gmtime_r() for Microsoft. Someone thought there
> was such a need.

I completely agree with Robert. And even go further...

HAVE_GMTIME_R should be unconditionally undefined for all builds if
(_MSC_VER) is defined.

Definition of HAVE_GMTIME_R for _MSC_VER builds seems to come from
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1230118&group_id=976

MS compilers do not have/use gmtime_r

The fact is that thread safeness on Windows is granted depending on
the CRT which is linked, not the name of the function.

But... caveat emptor. Using gmtime, localtime and mktime is a lot of
fun on Windows. All three use a single, _the_same_one_, statically
allocated buffer, and can even destroy its input. So the only way of
using them if you are using them more than once in the same piece of
code is making shadow copies of vars before passing them to the other
one.

This is already addressed at lib/parsedate.c lines 394 to 406 of revision 1.23

http://msdn.microsoft.com/library/en-us/vccore98/html/_crt_gmtime.asp
http://msdn.microsoft.com/library/en-us/vccore98/html/_crt_mktime.asp
http://msdn.microsoft.com/library/en-us/vccore98/html/_crt_localtime.asp

patch attached

-- 
-=[Yang]=-

Received on 2007-02-14