Thread (1 message) 1 message, 1 author, 2023-03-21

Re: [PATCH v2] git-compat-util: use gettimeofday(2) for time(2)

From: Junio C Hamano <hidden>
Date: 2023-03-21 16:20:20

Paul Eggert [off-list ref] writes:
Thanks, this looks good. As a matter of fact it almost precisely
matches what I was about to email you. The only significant difference
is that yours has "#define time(x) git_time(x)" whereas mine had
"#define time git_time". Since Git never takes the address of 'time'
the two macro definitions should have equivalent effects when used in
Git.
That is a valid concern.  Writing &time would not be caught by
compilers, and you would not notice such a mistake until you run "nm
-ug" on the result.

On the other hand, straight token replacement will risk renaming
variables and structure members, and I was not sure if we have such
use of the identifier "time".  As long as people do not use "time"
and "git_time" at the same time as such identifiers, that would not
be an issue (except for perhaps expecting to see them in debuggers).
Writing "git_time" and "time" at the same time for identifiers not
related to the time(2) function would not be caught by compilers,
either, but it feels much less likely mistake we would make in the
future, so let me drop (x) from the macro.

Thanks.

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help