Skip to content

Commit 02a37df

Browse files
Update CMakeLists.txt and logging.cpp for platform compatibility and warning suppression
- Added MSVC-specific definition to suppress getenv deprecation warnings in CMakeLists.txt. - Modified preprocessor directives in logging.cpp to use VNE_PLATFORM_WIN or _WIN32 for better compatibility across Windows platforms.
1 parent a54b467 commit 02a37df

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ elseif(VNE_TARGET_PLATFORM STREQUAL "iOS")
8383
target_link_libraries(vnelogging PRIVATE Foundation)
8484
endif()
8585

86+
# MSVC-specific: Suppress getenv deprecation warning (C4996)
87+
if(MSVC)
88+
target_compile_definitions(vnelogging PRIVATE _CRT_SECURE_NO_WARNINGS)
89+
endif()
90+
8691
# Set compile features
8792
target_compile_features(vnelogging PUBLIC cxx_std_20)
8893

src/vertexnova/logging/logging.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace {
3838
* @return Home directory path, or empty string if not found.
3939
*/
4040
std::string getHomeDirectory() {
41-
#if defined(VNE_PLATFORM_WINDOWS)
41+
#if defined(VNE_PLATFORM_WIN) || defined(_WIN32)
4242
if (const char* userprofile = std::getenv("USERPROFILE")) {
4343
return std::string(userprofile);
4444
}
@@ -55,7 +55,7 @@ std::string getHomeDirectory() {
5555
* @return Path separator ("/" or "\\").
5656
*/
5757
constexpr const char* getPathSeparator() {
58-
#if defined(VNE_PLATFORM_WINDOWS)
58+
#if defined(VNE_PLATFORM_WIN) || defined(_WIN32)
5959
return "\\";
6060
#else
6161
return "/";
@@ -254,7 +254,7 @@ std::string Logging::getPlatformSpecificLogDirectory() {
254254
const std::string sep = getPathSeparator();
255255
const std::string home = getHomeDirectory();
256256

257-
#if defined(VNE_PLATFORM_WINDOWS)
257+
#if defined(VNE_PLATFORM_WIN) || defined(_WIN32)
258258
// Windows: Use LocalAppData
259259
if (const char* appdata = std::getenv("LOCALAPPDATA")) {
260260
return std::string(appdata) + sep + "VertexNova" + sep + "logs";
@@ -319,7 +319,7 @@ std::string Logging::createLoggingFolder(const std::string& base_dir, const std:
319319
auto time = std::chrono::system_clock::to_time_t(now);
320320
std::tm timeinfo{};
321321

322-
#if defined(VNE_PLATFORM_WINDOWS)
322+
#if defined(VNE_PLATFORM_WIN) || defined(_WIN32)
323323
localtime_s(&timeinfo, &time);
324324
#else
325325
localtime_r(&time, &timeinfo);

0 commit comments

Comments
 (0)