Avoid redefining PRI macros on Linux (#4055)

* Avoid redefining `PRI` macros on Linux

The fixed width 64-bit integer types are defined differently per platform.
Some platforms define it as "long", others define it as "long long". For
consistency, `AZ::u64` or `AZ::s64` is always defined to "long long".
However, this causes problems for formatting those types, because on
platforms where `uint64_t` is a `long`, `PRIu64` gives the wrong format
string for `AZ::u64`. Previously this was fixed by redefining the `PRI`
macros so that they work for `AZ::u64`, but that breaks the ability to
format `uint64_t`.

We could add an AZ-specific version of the `PRI` macros for 64-bit integer
types, but we don't really need to, since they are `long long` on every
platform we support.

 * Use `%ll` for `AZ::u64`
 * Use `PRIu64` for `uint64_t`

Signed-off-by: Chris Burel <burelc@amazon.com>

* Avoid redefining `PRI` macros in CryCommon

Signed-off-by: Chris Burel <burelc@amazon.com>
This commit is contained in:
Chris Burel
2021-09-10 15:16:33 -07:00
committed by GitHub
parent 5bf749dcac
commit 72cd282ad2
10 changed files with 18 additions and 56 deletions
+3 -3
View File
@@ -2144,7 +2144,7 @@ namespace Audio
{
if (bytes < (1 << 10))
{
azsnprintf(buffer, bufLength, "%" PRIu64 " B", bytes);
azsnprintf(buffer, bufLength, "%llu B", bytes);
}
else if (bytes < (1 << 20))
{
@@ -2261,10 +2261,10 @@ namespace Audio
auxGeom.Draw2dLabel(fPosX + xTablePositions[4], posY + lineHeight, textSize, color, false, "%s", buffer);
auxGeom.Draw2dLabel(fPosX + xTablePositions[5], posY, textSize, color, false, "Total Allocs");
auxGeom.Draw2dLabel(fPosX + xTablePositions[5], posY + lineHeight, textSize, color, false, "%" PRIu64, totalAllocs);
auxGeom.Draw2dLabel(fPosX + xTablePositions[5], posY + lineHeight, textSize, color, false, "%llu", totalAllocs);
auxGeom.Draw2dLabel(fPosX + xTablePositions[6], posY, textSize, color, false, "Total Frees");
auxGeom.Draw2dLabel(fPosX + xTablePositions[6], posY + lineHeight, textSize, color, false, "%" PRIu64, totalFrees);
auxGeom.Draw2dLabel(fPosX + xTablePositions[6], posY + lineHeight, textSize, color, false, "%llu", totalFrees);
}
else
{