diff --git a/onnxruntime/core/framework/path_lib.h b/onnxruntime/core/framework/path_lib.h index 7845bbf535..3832fd5522 100644 --- a/onnxruntime/core/framework/path_lib.h +++ b/onnxruntime/core/framework/path_lib.h @@ -236,10 +236,9 @@ void LoopDir(const std::string& dir_name, T func) { auto e = errno; char buf[1024]; char* msg; -#if defined(_GNU_SOURCE) && !defined(__APPLE__) +#if defined(__GLIBC__) && defined(_GNU_SOURCE) msg = strerror_r(e, buf, sizeof(buf)); #else - // for Mac OS X if (strerror_r(e, buf, sizeof(buf)) != 0) { buf[0] = '\0'; } diff --git a/onnxruntime/core/platform/posix/env.cc b/onnxruntime/core/platform/posix/env.cc index 7cabf71753..92375f6f31 100644 --- a/onnxruntime/core/platform/posix/env.cc +++ b/onnxruntime/core/platform/posix/env.cc @@ -180,10 +180,9 @@ class PosixEnv : public Env { char buf[1024]; const char* msg = ""; if (e > 0) { -#if defined(_GNU_SOURCE) && !defined(__APPLE__) +#if defined(__GLIBC__) && defined(_GNU_SOURCE) msg = strerror_r(e, buf, sizeof(buf)); #else - // for Mac OS X if (strerror_r(e, buf, sizeof(buf)) != 0) { buf[0] = '\0'; }