git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Printing a uint64_t portably in Git?
@ 2020-02-06 17:52 Han-Wen Nienhuys
  2020-02-06 18:00 ` Martin Ågren
  0 siblings, 1 reply; 5+ messages in thread
From: Han-Wen Nienhuys @ 2020-02-06 17:52 UTC (permalink / raw)
  To: git

Hi,

The reftable patch is starting to shape up, but I still see failures on OSX,

See https://dev.azure.com/gitgitgadget/git/_build/results?buildId=29465&view=logs&j=cfa20e98-6997-523c-4233-f0a7302c929f&t=3de1ae02-4adb-5138-54da-65cec5dd3141&l=518

What is the right incantation to do printf of a uint64_t on OSX ?

Apparently PRIuMAX is to be used for "uintmax_t", and not for "long
long unsigned int".

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Printing a uint64_t portably in Git?
  2020-02-06 17:52 Printing a uint64_t portably in Git? Han-Wen Nienhuys
@ 2020-02-06 18:00 ` Martin Ågren
  2020-02-06 19:15   ` Han-Wen Nienhuys
  2020-02-06 21:11   ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Martin Ågren @ 2020-02-06 18:00 UTC (permalink / raw)
  To: Han-Wen Nienhuys; +Cc: git

On Thu, 6 Feb 2020 at 18:54, Han-Wen Nienhuys <hanwen@google.com> wrote:
> What is the right incantation to do printf of a uint64_t on OSX ?
>
> Apparently PRIuMAX is to be used for "uintmax_t", and not for "long
> long unsigned int".

You could cast it? Grepping around, that seems to be how PRIuMAX is
used:

  printf("%"PRIuMAX"\n", (uintmax_t)var);

Martin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Printing a uint64_t portably in Git?
  2020-02-06 18:00 ` Martin Ågren
@ 2020-02-06 19:15   ` Han-Wen Nienhuys
  2020-02-06 19:52     ` Martin Ågren
  2020-02-06 21:11   ` Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: Han-Wen Nienhuys @ 2020-02-06 19:15 UTC (permalink / raw)
  To: Martin Ågren; +Cc: git

On Thu, Feb 6, 2020 at 7:00 PM Martin Ågren <martin.agren@gmail.com> wrote:
>
> On Thu, 6 Feb 2020 at 18:54, Han-Wen Nienhuys <hanwen@google.com> wrote:
> > What is the right incantation to do printf of a uint64_t on OSX ?
> >
> > Apparently PRIuMAX is to be used for "uintmax_t", and not for "long
> > long unsigned int".
>
> You could cast it? Grepping around, that seems to be how PRIuMAX is
> used:
>
>   printf("%"PRIuMAX"\n", (uintmax_t)var);

Looks like the inttypes.h standard has the defines that I want.

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Printing a uint64_t portably in Git?
  2020-02-06 19:15   ` Han-Wen Nienhuys
@ 2020-02-06 19:52     ` Martin Ågren
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Ågren @ 2020-02-06 19:52 UTC (permalink / raw)
  To: Han-Wen Nienhuys; +Cc: git

On Thu, 6 Feb 2020 at 20:15, Han-Wen Nienhuys <hanwen@google.com> wrote:
>
> On Thu, Feb 6, 2020 at 7:00 PM Martin Ågren <martin.agren@gmail.com> wrote:
> >
> > On Thu, 6 Feb 2020 at 18:54, Han-Wen Nienhuys <hanwen@google.com> wrote:
> > > What is the right incantation to do printf of a uint64_t on OSX ?
> > >
> > > Apparently PRIuMAX is to be used for "uintmax_t", and not for "long
> > > long unsigned int".
> >
> > You could cast it? Grepping around, that seems to be how PRIuMAX is
> > used:
> >
> >   printf("%"PRIuMAX"\n", (uintmax_t)var);
>
> Looks like the inttypes.h standard has the defines that I want.

Oh, cool. We handle PRIuMAX and PRId64 in compat/mingw.h, but other than
that, it seems we rely on these being available. There's some discussion
in ebc3278665 ("git-compat-util.h: drop the `PRIuMAX` and other fallback
definitions", 2019-11-24).

Martin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Printing a uint64_t portably in Git?
  2020-02-06 18:00 ` Martin Ågren
  2020-02-06 19:15   ` Han-Wen Nienhuys
@ 2020-02-06 21:11   ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2020-02-06 21:11 UTC (permalink / raw)
  To: Martin Ågren; +Cc: Han-Wen Nienhuys, git

Martin Ågren <martin.agren@gmail.com> writes:

> On Thu, 6 Feb 2020 at 18:54, Han-Wen Nienhuys <hanwen@google.com> wrote:
>> What is the right incantation to do printf of a uint64_t on OSX ?
>>
>> Apparently PRIuMAX is to be used for "uintmax_t", and not for "long
>> long unsigned int".
>
> You could cast it? Grepping around, that seems to be how PRIuMAX is
> used:
>
>   printf("%"PRIuMAX"\n", (uintmax_t)var);

Yup, that is used already in existing code in our codebase, so it is
just as portable as the rest of Git is ;-)

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-06 21:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-06 17:52 Printing a uint64_t portably in Git? Han-Wen Nienhuys
2020-02-06 18:00 ` Martin Ågren
2020-02-06 19:15   ` Han-Wen Nienhuys
2020-02-06 19:52     ` Martin Ågren
2020-02-06 21:11   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).