Home

PRId64

PRId64 is a macro defined in the C standard library header inttypes.h. It expands to the correct length modifier for printing a value of type int64_t, a signed 64-bit integer, using printf-style functions. The macro is designed to provide a portable way to format 64-bit integers across different platforms and compilers.

Usage typically appears by concatenating a percent sign with the macro, for example: printf("%" PRId64 "\n", value);

The actual text of PRId64 varies by platform. On many Unix-like systems, int64_t corresponds to a long

PRId64 is part of a family of macros in inttypes.h that support portable formatting for integers. Related

In summary, PRId64 enables portable, decimal printing of 64-bit signed integers across diverse platforms.

This
approach
allows
the
exact
format
specifier
to
be
determined
by
the
platform,
so
the
same
code
prints
correctly
on
systems
where
64-bit
integers
have
different
underlying
representations
or
format
sequences.
int,
so
PRId64
may
expand
to
"ld"
or
"lld"
depending
on
the
environment.
On
Windows
with
MSVC,
it
may
expand
to
"I64d"
to
be
used
with
"%I64d".
The
important
point
is
that
combining
"%"
with
PRId64
yields
a
portable
decimal
format
for
int64_t.
macros
include
PRIu64
for
unsigned
decimal,
PRIx64/PRIo64
for
hexadecimal/octal,
and
their
corresponding
scanf
equivalents
such
as
SCNd64
and
SCNu64.
In
C++,
these
macros
are
available
via
<cinttypes>
and
used
in
the
same
way.