From be56eac8115779b1572e7d362f4b856797aeb326 Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Tue, 12 Oct 2021 17:02:07 +0200 Subject: [PATCH 1/6] Fixed constexpr function never produces a constant expression [-Winvalid-constexpr] --- src/common/Logging.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/Logging.h b/src/common/Logging.h index 687e86e71..532610949 100644 --- a/src/common/Logging.h +++ b/src/common/Logging.h @@ -293,8 +293,8 @@ constexpr const char* remove_prefix(const char* str, const char *prefix) { return (str_skip_prefix(str, prefix) == str + str_length(prefix)) ? str_skip_prefix(str, prefix) : str; } -static const char* xbox_prefix = "xbox::"; -static const char* emupatch_prefix = "EmuPatch_"; // See #define EMUPATCH +static constexpr const char* xbox_prefix = "xbox::"; +static constexpr const char* emupatch_prefix = "EmuPatch_"; // See #define EMUPATCH constexpr const char* remove_emupatch_prefix(const char* str) { // return an empty string when str isn't given From 309975da615df16c5adc659ae64b620fec163bdb Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Tue, 12 Oct 2021 17:06:31 +0200 Subject: [PATCH 2/6] Fixed subscript of pointer to incomplete type 'struct _XBE_SECTION' --- src/common/xbe/Xbe.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/xbe/Xbe.h b/src/common/xbe/Xbe.h index 130ce2fe9..bc19eabc1 100644 --- a/src/common/xbe/Xbe.h +++ b/src/common/xbe/Xbe.h @@ -28,6 +28,7 @@ #include "common\Error.h" #include "common/xbox/Types.hpp" +#include "core/kernel/common/types.h" #include From 4f26ab927ff59c74122f555f913d0866a7737366 Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Tue, 12 Oct 2021 17:22:52 +0200 Subject: [PATCH 3/6] Fixed explicit instantiation of undefined function template 'BindDefault' --- src/common/input/EmuDevice.cpp | 2 ++ src/common/input/EmuDevice.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/input/EmuDevice.cpp b/src/common/input/EmuDevice.cpp index 3b4caf5ce..03491d240 100644 --- a/src/common/input/EmuDevice.cpp +++ b/src/common/input/EmuDevice.cpp @@ -120,3 +120,5 @@ void EmuDevice::CreateTooltipWindow() SendMessage(m_tooltip_hwnd, TTM_SETMAXTIPWIDTH, 0, 500); SendMessage(m_tooltip_hwnd, TTM_SETDELAYTIME, TTDT_AUTOPOP, 15000); } + +template void EmuDevice::BindDefault(const std::array& arr); diff --git a/src/common/input/EmuDevice.h b/src/common/input/EmuDevice.h index e9a914467..c7c8b716c 100644 --- a/src/common/input/EmuDevice.h +++ b/src/common/input/EmuDevice.h @@ -53,4 +53,4 @@ private: HWND m_tooltip_hwnd; }; -template void EmuDevice::BindDefault(const std::array &arr); +extern template void EmuDevice::BindDefault(const std::array &arr); From 23c72d825ed147ead28093a4ded6cba57f0c7cec Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Tue, 12 Oct 2021 17:35:02 +0200 Subject: [PATCH 4/6] Fixed cannot pass object of non-trivial type 'std::vector' through variadic function; call will abort at runtime [-Wnon-pod-varargs] --- src/common/Logging.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/Logging.cpp b/src/common/Logging.cpp index 748ccc6b6..a260d5bf2 100644 --- a/src/common/Logging.cpp +++ b/src/common/Logging.cpp @@ -328,11 +328,11 @@ PopupReturn PopupCustomEx(const void* hwnd, const CXBXR_MODULE cxbxr_module, con va_list argp; va_start(argp, message); // allocate predicted buffer size then write to buffer afterward. - std::vector Buffer(1+std::vsnprintf(nullptr, 0, message, argp)); + std::string Buffer(1+std::vsnprintf(nullptr, 0, message, argp), '\0'); vsnprintf(Buffer.data(), Buffer.size(), message, argp); va_end(argp); - EmuLogOutputEx(cxbxr_module, level, "Popup : %s", Buffer); + EmuLogOutputEx(cxbxr_module, level, "Popup : %s", Buffer.c_str()); // If user is using exclusive fullscreen, we need to refrain all popups. if (g_disablePopupMessages) { From ca5a1aaa71f54ef8fb0657fb65a96d54ed52aaf3 Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Tue, 12 Oct 2021 18:44:09 +0200 Subject: [PATCH 5/6] Fixed non-const lvalue reference to type cannot bind to a temporary of type --- src/common/Settings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/Settings.cpp b/src/common/Settings.cpp index af16fdda7..c3574a6b9 100644 --- a/src/common/Settings.cpp +++ b/src/common/Settings.cpp @@ -496,7 +496,7 @@ bool Settings::LoadConfig() continue; } - auto &lambda = [&control_names, &device](int num_buttons, const char *const ctrl_names[]) { + const auto &lambda = [&control_names, &device](int num_buttons, const char *const ctrl_names[]) { for (int i = 0; i < num_buttons; i++) { char control_name[XBOX_BUTTON_NAME_LENGTH]; std::sprintf(control_name, sect_input_profiles.control, ctrl_names[i]); @@ -668,7 +668,7 @@ bool Settings::Save(std::string file_path) continue; } - auto &lambda = [&control_names, &device](int num_buttons, const char *const ctrl_names[]) { + const auto &lambda = [&control_names, &device](int num_buttons, const char *const ctrl_names[]) { for (int i = 0; i < num_buttons; i++) { char control_name[XBOX_BUTTON_NAME_LENGTH]; std::sprintf(control_name, sect_input_profiles.control, ctrl_names[i]); From 51c3f37596dde7a3215279c8031613a8717db746 Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Tue, 12 Oct 2021 19:02:42 +0200 Subject: [PATCH 6/6] Fixed non-const lvalue reference to type 'std::from_chars_result' cannot bind to a temporary of type 'std::from_chars_result' --- src/common/input/InputDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/input/InputDevice.cpp b/src/common/input/InputDevice.cpp index aa63b6dc7..e333cc7d4 100644 --- a/src/common/input/InputDevice.cpp +++ b/src/common/input/InputDevice.cpp @@ -109,7 +109,7 @@ std::string PortUserFormat(std::string_view port) void PortStr2Int(std::string_view port, int *port_num, int *slot) { *slot = PORT_INVALID; - auto &ret = std::from_chars(port.data(), port.data() + port.size(), *port_num); + auto ret = std::from_chars(port.data(), port.data() + port.size(), *port_num); assert(ret.ec != std::errc::invalid_argument); if (ret.ptr != port.data() + port.size()) { ++ret.ptr;