summaryrefslogtreecommitdiff
path: root/src/alloc-posix.c
diff options
context:
space:
mode:
authordaan <daanl@outlook.com>2020-09-04 13:06:18 -0700
committerdaan <daanl@outlook.com>2020-09-04 13:06:18 -0700
commit032eb2a75a868534e8130ea8eb32914f8040d211 (patch)
tree86576973036dd82fbca2db2de87f239f13475de7 /src/alloc-posix.c
parentd73d6beb71df5478f081be7fd1108a619ebba461 (diff)
use pragma warning only on msvc (issue #291)
Diffstat (limited to 'src/alloc-posix.c')
-rw-r--r--src/alloc-posix.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/alloc-posix.c b/src/alloc-posix.c
index 4395893..1ba1509 100644
--- a/src/alloc-posix.c
+++ b/src/alloc-posix.c
@@ -20,6 +20,10 @@ terms of the MIT license. A copy of the license can be found in the file
#include <string.h> // memcpy
#include <stdlib.h> // getenv
+#ifdef _MSC_VER
+#pragma warning(disable:4996) // getenv _wgetenv
+#endif
+
#ifndef EINVAL
#define EINVAL 22
#endif
@@ -111,8 +115,7 @@ mi_decl_restrict unsigned char* mi_mbsdup(const unsigned char* s) mi_attr_noexc
int mi_dupenv_s(char** buf, size_t* size, const char* name) mi_attr_noexcept {
if (buf==NULL || name==NULL) return EINVAL;
if (size != NULL) *size = 0;
- #pragma warning(suppress:4996)
- char* p = getenv(name);
+ char* p = getenv(name); // mscver warning 4996
if (p==NULL) {
*buf = NULL;
}
@@ -132,8 +135,7 @@ int mi_wdupenv_s(unsigned short** buf, size_t* size, const unsigned short* name)
*buf = NULL;
return EINVAL;
#else
- #pragma warning(suppress:4996)
- unsigned short* p = (unsigned short*)_wgetenv((const wchar_t*)name);
+ unsigned short* p = (unsigned short*)_wgetenv((const wchar_t*)name); // msvc warning 4996
if (p==NULL) {
*buf = NULL;
}