refactor: define WIN32_LEAN_AND_MEAN

This commit is contained in:
2026-04-16 21:56:33 +08:00
parent 876cb5ebe2
commit 278fcef295
2 changed files with 5 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <psapi.h> #include <psapi.h>
#else #else
@@ -15,12 +16,14 @@ inline size_t get_current_rss() {
return pmc.WorkingSetSize; return pmc.WorkingSetSize;
} }
return 0; return 0;
#else #elif defined(__linux__)
std::ifstream statm("/proc/self/statm"); std::ifstream statm("/proc/self/statm");
long vsz = 0, rss_pages = 0; long vsz = 0, rss_pages = 0;
statm >> vsz >> rss_pages; statm >> vsz >> rss_pages;
statm.close(); statm.close();
long page_size = sysconf(_SC_PAGESIZE); long page_size = sysconf(_SC_PAGESIZE);
return rss_pages * page_size; return rss_pages * page_size;
#else
return 0; // Unsupported platform
#endif #endif
} }

View File

@@ -4,6 +4,7 @@
#include <Cubed/tools/log.hpp> #include <Cubed/tools/log.hpp>
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
typedef LONG (WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); typedef LONG (WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
inline bool get_os_version(std::string& str) { inline bool get_os_version(std::string& str) {