localtime_r support on MinGW
I'm working on a Win32 multithread C++ project and I would like to use one
of the localtime_* thread-safe alternatives to localtime().
Unfortunately I have to use MinGW compiler, and localtime_s cannot be used
outside Microsoft stuff.
The problem is that neither localtime_r is working: the related code
snippet is
#include <ctime>
...
string getCurrentTime()
{
time_t t;
time(&t);
struct tm timeinfo;
//localtime_s(&timeinfo, &t);
localtime_r(&t, &timeinfo);
char buf[128];
strftime(buf, 128, "%d-%m-%Y %X", &timeinfo);
return string(buf);
}
...
This is the compiler output:
error: 'localtime_r' was not declared in this scope
Does MinGW support localtime_r ?
If not, does exist a thread-safe alternative? (excluding boost/QT/etc that
I can't use).
No comments:
Post a Comment