What is the Windows equivalent of the Unix function gmtime_r?

前端 未结 1 1077
粉色の甜心
粉色の甜心 2020-12-11 16:24

I am porting some Unix code into Windows Visual Studio 2010. I have run into the following line

gmtime_r(&now, &tm_time);

I found t

相关标签:
1条回答
  • 2020-12-11 17:26

    gmtime_r() is the thread-safe version of gmtime(). The MSVC implementation of gmtime() is already thread safe, the returned struct tm* is allocated in thread-local storage.

    That doesn't make it immune from trouble if the function is called multiple times on the same thread and the returned pointer is stored. You can use gmtime_s() instead. Closest to gmtime_r() but with the arguments reversed ;)

    0 讨论(0)
提交回复
热议问题