<<On Mon, 22 Jan 2024 17:00:26 -0700, Paul Gilmartin via tz <tz@iana.org> said:
But this answers my long confusion about why localtime() requires a reference, tine_t*, rather than merely a value. There may be no way to pass such an (opaque?) type on the stack.
time(), localtime(), and similar routines take a pointer because they predate the addition of `long int` to the C language: in the original implementation, the parameter was an array[2] of int, and of course you can't pass arrays by value in C. The arguments were left as pointers in V7 for binary compatibility with code that had not been converted to use `long`.[1] In contrast, interfaces added later, like ANSI C's mktime() and difftime(), use values instead. -GAWollman [1] Obviously this long predates ISO C's abstract machine model where there is a difference between types "pointer to array[2] of int" and "pointer to long", and of course `int` at the time, on a PDP-11, was 16 bits wide.