From 48229eef75c943fbfbae37ddd09b5f831afca5a8 Mon Sep 17 00:00:00 2001 From: Gnimuc Date: Sat, 11 Jan 2025 20:56:57 +0900 Subject: [PATCH] Restrict the use of `_s` (Annex K) functions to MSVC These `_s` secure functions are introduced in C11 as optional bounds-checking interfaces, there is no guarantee that they are implemented/enabled by other compilers. --- lib/Interpreter/Compatibility.h | 4 ++-- lib/Interpreter/CppInterOp.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Interpreter/Compatibility.h b/lib/Interpreter/Compatibility.h index d6efc7324..865d3d1d4 100644 --- a/lib/Interpreter/Compatibility.h +++ b/lib/Interpreter/Compatibility.h @@ -10,7 +10,7 @@ #include "clang/Basic/Version.h" #include "clang/Config/config.h" -#ifdef _WIN32 +#ifdef _MSC_VER #define dup _dup #define dup2 _dup2 #define close _close @@ -18,7 +18,7 @@ #endif static inline char* GetEnv(const char* Var_Name) { -#ifdef _WIN32 +#ifdef _MSC_VER char* Env = nullptr; size_t sz = 0; getenv_s(&sz, Env, sz, Var_Name); diff --git a/lib/Interpreter/CppInterOp.cpp b/lib/Interpreter/CppInterOp.cpp index d285ef9a1..56480082e 100644 --- a/lib/Interpreter/CppInterOp.cpp +++ b/lib/Interpreter/CppInterOp.cpp @@ -3414,7 +3414,7 @@ namespace Cpp { int m_DupFD = -1; public: -#ifdef _WIN32 +#ifdef _MSC_VER StreamCaptureInfo(int FD) : m_TempFile( []() {