The functions localtime_s
and asctime_s
are Microsoft-specific extensions, provided by (certain versions of) the MS runtime library. This is provided by the MS header files. Since those are copyright MS and not allowed for free distribution, mingw provides its own versions of headers - and these probably don't contain these extensions (they certainly didn't a while back when I was using mingw on my local machine - my main machine these days runs Linux...).
Note that casting the time value to time32_t *
is probably a bad idea - it is almost certainly going to bite you if you ever compile your code with a time_t
that isn't a 32-bit value.
The localtime_r
function is a semi-standard version that could be used instead of localtime_s
(you will need to pay attention to 32 vs 64-bit time values). You can certainly also use localtime
(aside from having to turn off MS's annoying "this function is not safe, please use ..._s
instead" - I don't REALLY want to convert my 100 uses of strcpy to strcpy_s that work perfectly fine because it has already been checked elsewhere).
Similarly there is asctime_r
which provides a re-entrant version.
You could, perhaps, also add the prototypes for these functions to your file somewhere, I believe that would, as long as you are compiling for Windows, solve the problem:
Link to MS function documentation: localtime_s
and asctime_s
.
localtime
, however that may be "non-reentrant". – Mats Petersson 8 hours agoasctime(buffer, &newtime)
– Mats Petersson 8 hours ago