Fix compilation warnings

This commit is contained in:
momo5502
2025-05-31 09:52:18 +02:00
parent 5c0a1ce5c2
commit c50fdd17a4
10 changed files with 54 additions and 59 deletions

View File

@@ -63,6 +63,14 @@ endif()
########################################## ##########################################
if(MINGW)
momo_add_c_and_cxx_compile_options(
-Wno-array-bounds
)
endif()
##########################################
if(LINUX) if(LINUX)
add_link_options( add_link_options(
-Wl,--no-undefined -Wl,--no-undefined

View File

@@ -10,7 +10,9 @@
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-function"
#endif #endif
#ifndef NOMINMAX
#define NOMINMAX #define NOMINMAX
#endif
#include <unicorn/unicorn.h> #include <unicorn/unicorn.h>
#ifdef __clang__ #ifdef __clang__

View File

@@ -20,11 +20,13 @@
#endif #endif
#ifdef OS_WINDOWS #ifdef OS_WINDOWS
#define EXPORT_SYMBOL __declspec(dllexport) #define EXPORT_SYMBOL __declspec(dllexport)
#define IMPORT_SYMBOL __declspec(dllimport) #define IMPORT_SYMBOL __declspec(dllimport)
#define NO_INLINE __declspec(noinline) #define NO_INLINE __declspec(noinline)
#ifndef DECLSPEC_ALIGN
#define DECLSPEC_ALIGN(n) __declspec(align(n)) #define DECLSPEC_ALIGN(n) __declspec(align(n))
#endif
#define RESTRICTED_POINTER #define RESTRICTED_POINTER

View File

@@ -72,8 +72,10 @@
#define SL_RETURN_SINGLE_ENTRY 0x02 #define SL_RETURN_SINGLE_ENTRY 0x02
#define SL_NO_CURSOR_UPDATE 0x10 #define SL_NO_CURSOR_UPDATE 0x10
#define SEC_IMAGE 0x01000000 #ifndef SEC_IMAGE
#define SEC_RESERVE 0x04000000 #define SEC_IMAGE 0x01000000
#define SEC_RESERVE 0x04000000
#endif
typedef enum _FSINFOCLASS typedef enum _FSINFOCLASS
{ {

View File

@@ -2,23 +2,24 @@
// NOLINTBEGIN(modernize-use-using) // NOLINTBEGIN(modernize-use-using)
#define PAGE_EXECUTE 0x10 #define PAGE_EXECUTE 0x10
#define PAGE_EXECUTE_READ 0x20 #define PAGE_EXECUTE_READ 0x20
#define PAGE_EXECUTE_READWRITE 0x40 #define PAGE_EXECUTE_READWRITE 0x40
#define PAGE_EXECUTE_WRITECOPY 0x80 #define PAGE_EXECUTE_WRITECOPY 0x80
#define PAGE_NOACCESS 0x01 #define PAGE_NOACCESS 0x01
#define PAGE_READONLY 0x02 #define PAGE_READONLY 0x02
#define PAGE_READWRITE 0x04 #define PAGE_READWRITE 0x04
#define PAGE_WRITECOPY 0x08 #define PAGE_WRITECOPY 0x08
#define PAGE_TARGETS_INVALID 0x40000000 #define PAGE_TARGETS_INVALID 0x40000000
#define PAGE_TARGETS_NO_UPDATE 0x40000000 #define PAGE_TARGETS_NO_UPDATE 0x40000000
#define PAGE_GUARD 0x100 #define PAGE_GUARD 0x100
#define PAGE_NOCACHE 0x200 #define PAGE_NOCACHE 0x200
#define PAGE_WRITECOMBINE 0x400 #define PAGE_WRITECOMBINE 0x400
#ifndef MEM_64K_PAGES
#define MEM_COMMIT 0x00001000 #define MEM_COMMIT 0x00001000
#define MEM_RESERVE 0x00002000 #define MEM_RESERVE 0x00002000
#define MEM_DECOMMIT 0x00004000 #define MEM_DECOMMIT 0x00004000
@@ -37,6 +38,7 @@
#define MEM_DOS_LIM 0x40000000 #define MEM_DOS_LIM 0x40000000
#define MEM_4MB_PAGES 0x80000000 #define MEM_4MB_PAGES 0x80000000
#define MEM_64K_PAGES (MEM_LARGE_PAGES | MEM_PHYSICAL) #define MEM_64K_PAGES (MEM_LARGE_PAGES | MEM_PHYSICAL)
#endif
typedef enum _MEMORY_INFORMATION_CLASS typedef enum _MEMORY_INFORMATION_CLASS
{ {
@@ -64,7 +66,11 @@ typedef enum _SECTION_INHERIT
ViewUnmap = 2 ViewUnmap = 2
} SECTION_INHERIT; } SECTION_INHERIT;
typedef struct DECLSPEC_ALIGN(16) _EMU_MEMORY_BASIC_INFORMATION64 typedef struct
#ifndef __MINGW64__
DECLSPEC_ALIGN(16)
#endif
_EMU_MEMORY_BASIC_INFORMATION64
{ {
uint64_t BaseAddress; uint64_t BaseAddress;
uint64_t AllocationBase; uint64_t AllocationBase;

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#ifdef _WIN32 #if defined(_WIN32) && !defined(__MINGW64__)
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) // nameless struct/union #pragma warning(disable : 4201) // nameless struct/union
#pragma warning(disable : 4702) // unreachable code #pragma warning(disable : 4702) // unreachable code
@@ -31,6 +31,6 @@
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
#ifdef OS_WINDOWS #if defined(_WIN32) && !defined(__MINGW64__)
#pragma warning(pop) #pragma warning(pop)
#endif #endif

View File

@@ -591,7 +591,11 @@ using NEON128 = struct _NEON128
LONGLONG High; LONGLONG High;
}; };
typedef struct DECLSPEC_ALIGN(16) _CONTEXT64 typedef struct
#if !defined(__MINGW64__)
DECLSPEC_ALIGN(16)
#endif
_CONTEXT64
{ {
DWORD64 P1Home; DWORD64 P1Home;
DWORD64 P2Home; DWORD64 P2Home;

View File

@@ -8,7 +8,7 @@ list(SORT SRC_FILES)
add_executable(test-sample ${SRC_FILES}) add_executable(test-sample ${SRC_FILES})
if(MINGW) if(WIN)
target_link_libraries(test-sample PRIVATE ws2_32) target_link_libraries(test-sample PRIVATE ws2_32)
endif() endif()

View File

@@ -9,7 +9,9 @@
#include <filesystem> #include <filesystem>
#include <string_view> #include <string_view>
#ifndef NOMINMAX
#define NOMINMAX #define NOMINMAX
#endif
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <intrin.h> #include <intrin.h>
@@ -23,8 +25,6 @@
#include <WS2tcpip.h> #include <WS2tcpip.h>
#endif #endif
#pragma comment(lib, "ws2_32.lib")
using namespace std::literals; using namespace std::literals;
// Externally visible and potentially modifiable state // Externally visible and potentially modifiable state
@@ -570,8 +570,10 @@ namespace
return false; return false;
} }
if (sendto(sender, send_data.data(), static_cast<int>(send_data.size()), 0, const auto sent_bytes = sendto(sender, send_data.data(), static_cast<int>(send_data.size()), 0,
reinterpret_cast<sockaddr*>(&destination), sizeof(destination)) != send_data.size()) reinterpret_cast<sockaddr*>(&destination), sizeof(destination));
if (static_cast<size_t>(sent_bytes) != send_data.size())
{ {
puts("Failed to send data!"); puts("Failed to send data!");
return false; return false;
@@ -593,6 +595,7 @@ namespace
return send_data == std::string_view(buffer, len); return send_data == std::string_view(buffer, len);
} }
#ifndef __MINGW64__
void throw_access_violation() void throw_access_violation()
{ {
if (do_the_task) if (do_the_task)
@@ -601,7 +604,6 @@ namespace
} }
} }
#ifndef __MINGW64__
bool test_access_violation_exception() bool test_access_violation_exception()
{ {
__try __try

View File

@@ -1,36 +1,5 @@
#pragma once #pragma once
#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable : 4005)
#pragma warning(disable : 4127)
#pragma warning(disable : 4201)
#pragma warning(disable : 4244)
#pragma warning(disable : 4245)
#pragma warning(disable : 4324)
#pragma warning(disable : 4458)
#pragma warning(disable : 4471)
#pragma warning(disable : 4505)
#pragma warning(disable : 4702)
#pragma warning(disable : 4996)
#pragma warning(disable : 5054)
#pragma warning(disable : 6011)
#pragma warning(disable : 6297)
#pragma warning(disable : 6385)
#pragma warning(disable : 6386)
#pragma warning(disable : 6387)
#pragma warning(disable : 26110)
#pragma warning(disable : 26451)
#pragma warning(disable : 26444)
#pragma warning(disable : 26451)
#pragma warning(disable : 26489)
#pragma warning(disable : 26495)
#pragma warning(disable : 26498)
#pragma warning(disable : 26812)
#pragma warning(disable : 28020)
#pragma warning(pop)
#endif
#include <map> #include <map>
#include <set> #include <set>
#include <list> #include <list>