Fix msvc compiler warnings (#374)

To be noticed I edited thirdparty header for fmt library (#373), idk if
it is acceptable
This commit is contained in:
GEEKiDoS
2025-09-19 12:57:38 +08:00
committed by GitHub
parent 4e138b244e
commit 808ac0c557
9 changed files with 36 additions and 5 deletions
+19
View File
@@ -80,6 +80,25 @@ if(MSVC)
# enable COMDAT folding for even smaller release builds # enable COMDAT folding for even smaller release builds
add_link_options("$<$<CONFIG:RELEASE,MINSIZEREL>:/OPT:ICF>") add_link_options("$<$<CONFIG:RELEASE,MINSIZEREL>:/OPT:ICF>")
# always use UTF-8 (fix 4819)
add_compile_options("/utf-8")
# spectre mitigation warning
add_compile_options("/wd5045")
# implicit type convert warnings
add_compile_options("/wd4244")
add_compile_options("/wd4267")
add_compile_options("/wd4305")
# unreferenced local variable
add_compile_options("/wd4101")
# warning in winbase.h??
add_compile_options("/wd5039")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# disable warnings about using non _s variants like strncpy # disable warnings about using non _s variants like strncpy
add_compile_definitions(_CRT_SECURE_NO_WARNINGS) add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
+1 -1
View File
@@ -373,7 +373,7 @@ void ICCADevice::update_card(int unit) {
bool kb_insert_press = false; bool kb_insert_press = false;
// eamio keypress // eamio keypress
kb_insert_press |= eamuse_get_keypad_state((size_t) unit) & (1 << EAM_IO_INSERT); kb_insert_press |= static_cast<bool>(eamuse_get_keypad_state((size_t) unit) & (1 << EAM_IO_INSERT));
// check for card // check for card
if (this->cards[unit] == nullptr && (eamuse_card_insert_consume(this->node_count, unit) || kb_insert_press)) { if (this->cards[unit] == nullptr && (eamuse_card_insert_consume(this->node_count, unit) || kb_insert_press)) {
+4
View File
@@ -1527,8 +1527,10 @@ FMT_CONSTEXPR auto make_arg(const T& value) -> basic_format_arg<Context> {
return arg; return arg;
} }
#ifdef __GNUC__
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-reference" #pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
// The type template parameter is there to avoid an ODR violation when using // The type template parameter is there to avoid an ODR violation when using
// a fallback formatter in one translation unit and an implicit conversion in // a fallback formatter in one translation unit and an implicit conversion in
@@ -1544,7 +1546,9 @@ FMT_CONSTEXPR FMT_INLINE auto make_arg(const T& val) -> value<Context> {
return arg; return arg;
} }
#ifdef __GNUC__
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
template <bool IS_PACKED, typename Context, type, typename T, template <bool IS_PACKED, typename Context, type, typename T,
FMT_ENABLE_IF(!IS_PACKED)> FMT_ENABLE_IF(!IS_PACKED)>
+1 -1
View File
@@ -14,7 +14,7 @@ namespace games::ccj {
bool MOUSE_TRACKBALL_USE_TOGGLE = false; bool MOUSE_TRACKBALL_USE_TOGGLE = false;
uint8_t TRACKBALL_SENSITIVITY = 10; uint8_t TRACKBALL_SENSITIVITY = 10;
static HANDLE fakeHandle = (HANDLE)0xDEADBEEF; static HANDLE fakeHandle = (HANDLE)0xDEADBEEFull;
static HWND hWnd = nullptr; static HWND hWnd = nullptr;
static WNDPROC wndProc = nullptr; static WNDPROC wndProc = nullptr;
static std::thread *tbThread = nullptr; static std::thread *tbThread = nullptr;
+1 -1
View File
@@ -94,7 +94,7 @@ namespace games::otoca {
bool kb_insert_press = false; bool kb_insert_press = false;
// eamio keypress // eamio keypress
kb_insert_press |= eamuse_get_keypad_state(0) & (1 << EAM_IO_INSERT); kb_insert_press |= static_cast<bool>(eamuse_get_keypad_state(0) & (1 << EAM_IO_INSERT));
// check for card // check for card
if (CARD_DATA == nullptr && (eamuse_card_insert_consume(1, 0) || kb_insert_press)) { if (CARD_DATA == nullptr && (eamuse_card_insert_consume(1, 0) || kb_insert_press)) {
+4
View File
@@ -141,13 +141,17 @@ static ULONG WINAPI GetAdaptersInfo_hook(PIP_ADAPTER_INFO pAdapterInfo, PULONG p
static int WINAPI bind_hook(SOCKET s, const struct sockaddr *name, int namelen) { static int WINAPI bind_hook(SOCKET s, const struct sockaddr *name, int namelen) {
#ifdef __clang__
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma ide diagnostic ignored "OCDFAInspection" #pragma ide diagnostic ignored "OCDFAInspection"
#endif
// cast to sockaddr_in // cast to sockaddr_in
struct sockaddr_in *in_name = (struct sockaddr_in *) name; struct sockaddr_in *in_name = (struct sockaddr_in *) name;
#ifdef __clang__
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif
// override bind to allow all hosts // override bind to allow all hosts
in_name->sin_addr.s_addr = inet_addr("0.0.0.0"); in_name->sin_addr.s_addr = inet_addr("0.0.0.0");
+1 -1
View File
@@ -2445,7 +2445,7 @@ std::unique_ptr<std::vector<Option>> launcher::parse_options(int argc, char *arg
} else { } else {
// validate it is an integer // validate it is an integer
try { try {
std::stoull(argv[i], nullptr, 16); auto _ = std::stoull(argv[i], nullptr, 16);
} catch (const std::exception &ex) { } catch (const std::exception &ex) {
log_fatal("options", "parameter for -{} is not a hex number: {}", alias, argv[i]); log_fatal("options", "parameter for -{} is not a hex number: {}", alias, argv[i]);
} }
+1 -1
View File
@@ -162,7 +162,7 @@ static void __cdecl cardunit_update() {
bool kb_insert_press = false; bool kb_insert_press = false;
// eamio keypress // eamio keypress
kb_insert_press |= eamuse_get_keypad_state(unit) & (1 << EAM_IO_INSERT); kb_insert_press |= static_cast<bool>(eamuse_get_keypad_state(unit) & (1 << EAM_IO_INSERT));
// update card inserts // update card inserts
if (eamuse_card_insert_consume((int) EXTDEV_CARDUNIT_COUNT, unit) || if (eamuse_card_insert_consume((int) EXTDEV_CARDUNIT_COUNT, unit) ||
+4
View File
@@ -106,8 +106,10 @@ bool detour::inline_restore(void *address, char *data) {
#endif #endif
} }
#ifdef __clang__
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma ide diagnostic ignored "OCDFAInspection" #pragma ide diagnostic ignored "OCDFAInspection"
#endif
static void *pe_offset(void *ptr, size_t offset) { static void *pe_offset(void *ptr, size_t offset) {
if (offset == 0) { if (offset == 0) {
@@ -282,7 +284,9 @@ void **detour::iat_find_proc(const char *iid_name, void *proc, HMODULE module) {
return nullptr; return nullptr;
} }
#ifdef __clang__
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif
void *detour::iat_try(const char *function, void *new_func, HMODULE module, const char *iid_name) { void *detour::iat_try(const char *function, void *new_func, HMODULE module, const char *iid_name) {