I have a large project about static source code analysis, and everything compiles successfully, except for one thing. I have provided the error message in the title. The poi
std::ctime
is not thread safe for two reasons:
std::tm
that is shared by multiple functions.char
array and returns a pointer to that array.There is a potential for collisions if you have other threads that call std::gmtime
, std::localtime
, or std::ctime
.
The best thing to do is to convert that call to std::ctime
to a call to std::strftime
. This is consistent with POSIX, which deems ctime
to be obsolete and recommends usage of strftime
in its stead.