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
@@ -699,7 +699,7 @@ Please note that only those seed files will get updated that are active for your
if (isMove)
{
report.append(AZStd::string::format(
"SOURCEID: %" PRId64 ", CURRENT PATH: %s, NEW PATH: %s, CURRENT GUID: %s, NEW GUID: %s\n",
"SOURCEID: %lld, CURRENT PATH: %s, NEW PATH: %s, CURRENT GUID: %s, NEW GUID: %s\n",
relocationInfo.m_sourceEntry.m_sourceID,
relocationInfo.m_oldRelativePath.c_str(),
relocationInfo.m_newRelativePath.c_str(),
@@ -709,7 +709,7 @@ Please note that only those seed files will get updated that are active for your
else
{
report.append(AZStd::string::format(
"SOURCEID: %" PRId64 ", CURRENT PATH: %s, CURRENT GUID: %s\n",
"SOURCEID: %lld, CURRENT PATH: %s, CURRENT GUID: %s\n",
relocationInfo.m_sourceEntry.m_sourceID,
relocationInfo.m_oldRelativePath.c_str(),
relocationInfo.m_sourceEntry.m_sourceGuid.ToString<AZStd::string>().c_str()));
@@ -1018,7 +1018,7 @@ namespace AssetUtilities
AZStd::string ComputeJobLogFileName(const AzToolsFramework::AssetSystem::JobInfo& jobInfo)
{
return AZStd::string::format("%s-%u-%" PRIu64 ".log", jobInfo.m_sourceFile.c_str(), jobInfo.GetHash(), jobInfo.m_jobRunKey);
return AZStd::string::format("%s-%u-%llu.log", jobInfo.m_sourceFile.c_str(), jobInfo.GetHash(), jobInfo.m_jobRunKey);
}
AZStd::string ComputeJobLogFileName(const AssetBuilderSDK::CreateJobsRequest& createJobsRequest)
@@ -1287,13 +1287,13 @@ namespace AssetUtilities
// so we add the size of it too.
// its also possible that it moved to a different file with the same modtime/hash AND size,
// but with a different name. So we add that too.
return AZStd::string::format("%" PRIX64 ":%" PRIu64 ":%s", fileIdentifier, fileStateInfo.m_fileSize, nameToUse.c_str());
return AZStd::string::format("%llX:%llu:%s", fileIdentifier, fileStateInfo.m_fileSize, nameToUse.c_str());
}
}
AZStd::string ComputeJobLogFileName(const AssetProcessor::JobEntry& jobEntry)
{
return AZStd::string::format("%s-%u-%" PRIu64 ".log", jobEntry.m_databaseSourceName.toUtf8().constData(), jobEntry.GetHash(), jobEntry.m_jobRunKey);
return AZStd::string::format("%s-%u-%llu.log", jobEntry.m_databaseSourceName.toUtf8().constData(), jobEntry.GetHash(), jobEntry.m_jobRunKey);
}
bool CreateTempRootFolder(QString startFolder, QDir& tempRoot)