From 09dc3a5592a1a4b4c341e10a0579783c0d74d6d8 Mon Sep 17 00:00:00 2001 From: kongfl888 K Date: Fri, 14 Jun 2024 19:23:07 +0800 Subject: [PATCH] Fix gcc 13+ compilation and update fmt. (#142) * Soc and artic_bass: gcc 13+ compatibility fix. * externals/fmt: update to HEAD fcd3e1e19. It will fix error. integer_sequence [-Werror=tautological-compare] The updating is helpful and needed. Fmt has gone through two public versions since its last update and has fixed many bugs, including new compiler optimizations. But neither of these two public versions can fix the errors encountered above. We need to switch to a working version. It can be fixed after fmt/8e62172.There are still many optimizations, Such as this one: Std. h c++23 build fix (# 3856) And these: C++23 compatibility: basicstring_view cannot be constructed from nullptr (# 3846) Fix warning C4702 emitted from format.h (MSVC) (#3866) Of course, there are other functional improvements as well. Very helpful. The selected version is the one that has been checked and works well. And synchronously updating local code. * citra_qt/ui: clean up duplicate naming warnings. --- externals/fmt | 2 +- src/citra_qt/configuration/configure_debug.ui | 6 +++--- src/common/logging/formatter.h | 4 ++-- src/core/hle/service/cfg/cfg.cpp | 2 +- src/core/hle/service/ir/extra_hid.cpp | 2 +- src/core/hle/service/ir/ir_user.cpp | 2 +- src/core/hle/service/soc/soc_u.cpp | 11 ++++------- src/core/hle/service/soc/soc_u.h | 4 ++-- src/core/movie.cpp | 1 + src/core/savestate.cpp | 2 +- src/network/artic_base/artic_base_client.cpp | 8 ++++---- src/video_core/renderer_software/sw_clipper.cpp | 1 + src/video_core/renderer_vulkan/vk_instance.cpp | 2 +- src/video_core/renderer_vulkan/vk_shader_util.cpp | 1 + 14 files changed, 24 insertions(+), 24 deletions(-) diff --git a/externals/fmt b/externals/fmt index 2dd4fa8742..fcd3e1e19c 160000 --- a/externals/fmt +++ b/externals/fmt @@ -1 +1 @@ -Subproject commit 2dd4fa8742fdac36468f8d8ea3e06e78215551f8 +Subproject commit fcd3e1e19c8d2df94bb6cb40d7f1c97a9872cf2b diff --git a/src/citra_qt/configuration/configure_debug.ui b/src/citra_qt/configuration/configure_debug.ui index eacf85be9c..860df0ffed 100644 --- a/src/citra_qt/configuration/configure_debug.ui +++ b/src/citra_qt/configuration/configure_debug.ui @@ -86,7 +86,7 @@ - + @@ -100,7 +100,7 @@ - + @@ -125,7 +125,7 @@ CPU - + diff --git a/src/common/logging/formatter.h b/src/common/logging/formatter.h index ad6adb1435..1bfd534b5b 100644 --- a/src/common/logging/formatter.h +++ b/src/common/logging/formatter.h @@ -12,9 +12,9 @@ #if FMT_VERSION >= 80100 template struct fmt::formatter, char>> - : formatter> { + : fmt::formatter> { template - auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) { + auto format(const T& value, FormatContext& ctx) const -> decltype(ctx.out()) { return fmt::formatter>::format( static_cast>(value), ctx); } diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index 8643692154..1fa50e1df0 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "common/archives.h" #include "common/file_util.h" #include "common/logging/log.h" diff --git a/src/core/hle/service/ir/extra_hid.cpp b/src/core/hle/service/ir/extra_hid.cpp index e159a70fec..2483a27f08 100644 --- a/src/core/hle/service/ir/extra_hid.cpp +++ b/src/core/hle/service/ir/extra_hid.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include +#include #include "common/alignment.h" #include "common/settings.h" #include "core/core_timing.h" diff --git a/src/core/hle/service/ir/ir_user.cpp b/src/core/hle/service/ir/ir_user.cpp index add0eb3d0a..597fdc4b6a 100644 --- a/src/core/hle/service/ir/ir_user.cpp +++ b/src/core/hle/service/ir/ir_user.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include "common/archives.h" #include "common/swap.h" #include "core/core.h" diff --git a/src/core/hle/service/soc/soc_u.cpp b/src/core/hle/service/soc/soc_u.cpp index 1ef35da26e..a400842493 100644 --- a/src/core/hle/service/soc/soc_u.cpp +++ b/src/core/hle/service/soc/soc_u.cpp @@ -2236,18 +2236,15 @@ std::optional SOC_U::GetDefaultInterfaceInfo() { } InterfaceInfo ret; -#ifdef _WIN32 - SOCKET sock_fd = -1; -#else - int sock_fd = -1; -#endif + + SocketHolder::SOCKET sock_fd = -1; bool interface_found = false; struct sockaddr_in s_in = {.sin_family = AF_INET, .sin_port = htons(53), .sin_addr = {}}; s_in.sin_addr.s_addr = inet_addr("8.8.8.8"); socklen_t s_info_len = sizeof(struct sockaddr_in); sockaddr_in s_info; - if (static_cast(sock_fd = ::socket(AF_INET, SOCK_STREAM, 0)) == -1) { + if ((sock_fd = ::socket(AF_INET, SOCK_STREAM, 0)) == static_cast(-1)) { return std::nullopt; } @@ -2265,7 +2262,7 @@ std::optional SOC_U::GetDefaultInterfaceInfo() { #ifdef _WIN32 sock_fd = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0); - if (static_cast(sock_fd) == SOCKET_ERROR) { + if (sock_fd == static_cast(SOCKET_ERROR)) { return std::nullopt; } diff --git a/src/core/hle/service/soc/soc_u.h b/src/core/hle/service/soc/soc_u.h index 2a7cfa8e83..b66607698b 100644 --- a/src/core/hle/service/soc/soc_u.h +++ b/src/core/hle/service/soc/soc_u.h @@ -25,11 +25,11 @@ namespace Service::SOC { struct SocketHolder { #ifdef _WIN32 using SOCKET = unsigned long long; - SOCKET socket_fd; ///< The socket descriptor #else - int socket_fd; ///< The socket descriptor + using SOCKET = int; #endif // _WIN32 + SOCKET socket_fd; ///< The socket descriptor bool blocking = true; ///< Whether the socket is blocking or not. bool isGlobal = false; bool shutdown_rd = false; diff --git a/src/core/movie.cpp b/src/core/movie.cpp index c7dd23c904..ee6bf35773 100644 --- a/src/core/movie.cpp +++ b/src/core/movie.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "common/archives.h" #include "common/bit_field.h" #include "common/file_util.h" diff --git a/src/core/savestate.cpp b/src/core/savestate.cpp index bb750d0c98..ad8e57ffb1 100644 --- a/src/core/savestate.cpp +++ b/src/core/savestate.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "common/archives.h" #include "common/file_util.h" #include "common/logging/log.h" diff --git a/src/network/artic_base/artic_base_client.cpp b/src/network/artic_base/artic_base_client.cpp index 5de5316620..460d8f9ee6 100644 --- a/src/network/artic_base/artic_base_client.cpp +++ b/src/network/artic_base/artic_base_client.cpp @@ -163,7 +163,7 @@ bool Client::Connect() { } main_socket = ::socket(AF_INET, SOCK_STREAM, 0); - if (main_socket == -1) { + if (main_socket == static_cast(-1)) { LOG_ERROR(Network, "Failed to create socket"); SignalCommunicationError(); return false; @@ -249,7 +249,7 @@ bool Client::Connect() { std::stringstream ss_port(worker_ports.value()); while (std::getline(ss_port, str_port, ',')) { int port = str_to_int(str_port); - if (port < 0 || port > USHRT_MAX) { + if (port < 0 || port > static_cast(USHRT_MAX)) { shutdown(main_socket, SHUT_RDWR); closesocket(main_socket); LOG_ERROR(Network, "Couldn't parse server worker ports"); @@ -518,7 +518,7 @@ std::optional Client::SendRequestPacket( const std::chrono::nanoseconds& read_timeout) { std::scoped_lock l(send_mutex); - if (main_socket == -1) { + if (main_socket == static_cast(-1)) { return std::nullopt; } @@ -586,7 +586,7 @@ Client::Handler::Handler(Client& _client, u32 _addr, u16 _port, int _id) void Client::Handler::RunLoop() { handler_socket = ::socket(AF_INET, SOCK_STREAM, 0); - if (handler_socket == -1) { + if (handler_socket == static_cast(-1)) { LOG_ERROR(Network, "Failed to create socket"); return; } diff --git a/src/video_core/renderer_software/sw_clipper.cpp b/src/video_core/renderer_software/sw_clipper.cpp index 03a287a37d..531eb0175b 100644 --- a/src/video_core/renderer_software/sw_clipper.cpp +++ b/src/video_core/renderer_software/sw_clipper.cpp @@ -4,6 +4,7 @@ #include #include +#include #include "video_core/pica/regs_texturing.h" #include "video_core/renderer_software/sw_clipper.h" diff --git a/src/video_core/renderer_vulkan/vk_instance.cpp b/src/video_core/renderer_vulkan/vk_instance.cpp index 8f77f25e01..2d91ff2209 100644 --- a/src/video_core/renderer_vulkan/vk_instance.cpp +++ b/src/video_core/renderer_vulkan/vk_instance.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include "common/assert.h" #include "common/settings.h" diff --git a/src/video_core/renderer_vulkan/vk_shader_util.cpp b/src/video_core/renderer_vulkan/vk_shader_util.cpp index 09e3eb883f..3d2f2f1d1f 100644 --- a/src/video_core/renderer_vulkan/vk_shader_util.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_util.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include #include #include