[tz] mktime() clarification
Clive D.W. Feather
clive at davros.org
Mon Mar 25 20:34:28 UTC 2024
Dag-Erling Smrgrav said:
> "Clive D.W. Feather via tz" <tz at iana.org> writes:
> > Dag-Erling Smørgrav <des at des.no> writes:
> > > [...] POSIX never guarantees that a successful call does not modify
> > > errno [...]
> > Library functions and system calls never set errno to 0. So the usual
> > answer is to set errno to 0 before the call and see if it's still 0
> > afterwards.
>
> See above, and try this:
>
> struct tm tm = { .tm_mday = 1, .tm_year = 69 };
> errno = 0;
> printf("%ld %d\n", mktime(&tm), errno);
There is no requirement in the C99 Standard (I dropped out of WG14 shortly
after) that the call to mktime is made before the value of errno is read.
--
Clive D.W. Feather | If you lie to the compiler,
Email: clive at davros.org | it will get its revenge.
Web: http://www.davros.org | - Henry Spencer
Mobile: +44 7973 377646
More information about the tz
mailing list