From 0011fb4b2b9908b850608d9924a002fcabe3997b Mon Sep 17 00:00:00 2001 From: Ziemas Date: Sun, 18 Feb 2024 02:16:46 +0100 Subject: [PATCH] Fix remaining cpp20 issues (#3375) --- game/CMakeLists.txt | 3 --- game/kernel/common/Ptr.h | 4 ++-- game/kernel/common/kmemcard.cpp | 4 ++-- game/sound/CMakeLists.txt | 2 -- test/CMakeLists.txt | 2 -- test/goalc/framework/test_runner.cpp | 2 +- test/goalc/test_vector_float.cpp | 10 +++++----- 7 files changed, 10 insertions(+), 17 deletions(-) diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index caeb585a8..b2ed91b6a 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -1,6 +1,3 @@ -# We define our own compilation flags here. -set(CMAKE_CXX_STANDARD 17) - # Set a more convenient ARM flag if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") set(ARM64_ARCH TRUE) diff --git a/game/kernel/common/Ptr.h b/game/kernel/common/Ptr.h index b55f4ee7b..7b01cc116 100644 --- a/game/kernel/common/Ptr.h +++ b/game/kernel/common/Ptr.h @@ -53,8 +53,8 @@ struct Ptr { Ptr operator+(s32 diff) { return Ptr(offset + diff); } s32 operator-(Ptr x) { return offset - x.offset; } Ptr operator-(s32 diff) { return Ptr(offset - diff); } - bool operator==(const Ptr& x) { return offset == x.offset; } - bool operator!=(const Ptr& x) { return offset != x.offset; } + bool operator==(const Ptr& x) const { return offset == x.offset; } + bool operator!=(const Ptr& x) const { return offset != x.offset; } /*! * Convert to a C pointer. diff --git a/game/kernel/common/kmemcard.cpp b/game/kernel/common/kmemcard.cpp index d4f64f2f9..064938570 100644 --- a/game/kernel/common/kmemcard.cpp +++ b/game/kernel/common/kmemcard.cpp @@ -60,9 +60,9 @@ void mc_print(const std::string& str, Args&&... args) { if (memcard_debug) { fmt::print("[MC] "); if (!str.empty() && str.back() == '\n') { - fmt::print(str, std::forward(args)...); + fmt::print(fmt::runtime(str), std::forward(args)...); } else { - fmt::print(str + '\n', std::forward(args)...); + fmt::print(fmt::runtime(str + '\n'), std::forward(args)...); } } } diff --git a/game/sound/CMakeLists.txt b/game/sound/CMakeLists.txt index 4804d844d..f0f5adbf2 100644 --- a/game/sound/CMakeLists.txt +++ b/game/sound/CMakeLists.txt @@ -1,5 +1,3 @@ -set(CMAKE_CXX_STANDARD 17) - set(SOUND_SOURCES 989snd/player.cpp 989snd/midi_handler.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ea4f227c7..112d57514 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,3 @@ -set(CMAKE_CXX_STANDARD 17) - include(${CMAKE_CURRENT_LIST_DIR}/goalc/CMakeLists.txt) include(${CMAKE_CURRENT_LIST_DIR}/offline/CMakeLists.txt) diff --git a/test/goalc/framework/test_runner.cpp b/test/goalc/framework/test_runner.cpp index b01ac3e0f..42ae7cb29 100644 --- a/test/goalc/framework/test_runner.cpp +++ b/test/goalc/framework/test_runner.cpp @@ -37,7 +37,7 @@ std::string escaped_string(const std::string& in) { std::string CompilerTestRunner::test_file_name(std::string templateStr) { const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); - std::string outFile = fmt::format(templateStr, test_info->name()); + std::string outFile = fmt::format(fmt::runtime(templateStr), test_info->name()); std::replace(outFile.begin(), outFile.end(), '/', '_'); return outFile; } diff --git a/test/goalc/test_vector_float.cpp b/test/goalc/test_vector_float.cpp index 1df45c980..b5c8d30ed 100644 --- a/test/goalc/test_vector_float.cpp +++ b/test/goalc/test_vector_float.cpp @@ -166,7 +166,7 @@ struct VectorFloatTestCase_TwoOperand : VectorFloatTestCase { input1.setJson(data, "v1"); input2.setJson(data, "v2"); dest.setJson(data, "dest"); - data["operation"] = fmt::format(func); + data["operation"] = fmt::format("{}", func); if (destinationMask == -1) { data["destinationMask"] = false; } else { @@ -301,7 +301,7 @@ struct VectorFloatTestCase_SingleOperand : VectorFloatTestCase { void setJson(nlohmann::json& data, std::string func) { input1.setJson(data, "v1"); dest.setJson(data, "dest"); - data["operation"] = fmt::format(func); + data["operation"] = fmt::format("{}", func); if (destinationMask == -1) { data["destinationMask"] = false; } else { @@ -377,7 +377,7 @@ struct VectorFloatTestCase_TwoOperandACC : VectorFloatTestCase { input2.setJson(data, "v2"); acc.setJson(data, "acc"); dest.setJson(data, "dest"); - data["operation"] = fmt::format(func); + data["operation"] = fmt::format("{}", func); if (destinationMask == -1) { data["destinationMask"] = false; } else { @@ -473,7 +473,7 @@ struct VectorFloatTestCase_TwoOperandQuotient : VectorFloatTestCase { input1.setJson(data, "v1"); input2.setJson(data, "v2"); dest.setJson(data, "dest"); - data["operation"] = fmt::format(func); + data["operation"] = fmt::format("{}", func); data["ftf"] = fmt::format("{:b}", ftf); data["fsf"] = fmt::format("{:b}", fsf); } @@ -542,7 +542,7 @@ struct VectorFloatTestCase_OneOperandQuotient : VectorFloatTestCase { void setJson(nlohmann::json& data, std::string func) { input1.setJson(data, "v1"); dest.setJson(data, "dest"); - data["operation"] = fmt::format(func); + data["operation"] = fmt::format("{}", func); data["ftf"] = fmt::format("{:b}", ftf); } };