Re: [PATCH 3/6] Introduce a new "printf format" for timestamps
From: Junio C Hamano <hidden>
Date: 2017-03-01 20:11:01
Junio C Hamano [off-list ref] writes:
Johannes Schindelin [off-list ref] writes:quoted
So let's introduce the pseudo format "PRItime" (currently simply being "lu") so that it is easy later on to change the data type to time_t.The problem being solved is a good thing to solve, andquoted
- printf("author-time %lu\n", ci.author_time); + printf("author-time %"PRItime"\n", ci.author_time);... It would be better to introduce the timestamp_t we discussed earlier before (or at) this step, and typedef it to ulong first, and then in this step, change the above to printf("author-time %"PRItime"\n", (timestamp_t)ci.author_time); to keep them in sync.
Nah, ignore me. This was just me being silly.
I was somehow expecting (incorrecty) that we would pick one single
PRItime for everybody and end up doing an equivalent of
printf("%llu", (unsigned long long)(something_that_is_time_t))
But as long as the plan is to configure PRItime for the platform's
time_t (or whatever the final type for timestamp_t is), we do not
have to have any extra cast here. The endgame will use the type
that is consistent with %PRItime for variables and structure fields,
and we do not want an extra cast.