From 0637780a1f6e49d4ec9026e24ba941bbd9991833 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Sat, 28 Jan 2017 19:43:50 -0800 Subject: [PATCH] char ** enivron is inconsistent on some platforms Summary: The forward declaration of `extern char ** environ` is inconsistent on some platforms. Reviewed By: strager, Orvid Differential Revision: D4474856 fbshipit-source-id: c73a7c7d5a247e962fab06aeb65df7815f0e3bcb --- folly/portability/Stdlib.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/folly/portability/Stdlib.h b/folly/portability/Stdlib.h index 3aca93bf..9b16d760 100644 --- a/folly/portability/Stdlib.h +++ b/folly/portability/Stdlib.h @@ -18,6 +18,13 @@ #include +#if defined(__APPLE__) +#include +#if (TARGET_OS_OSX || TARGET_OS_SIMULATOR) +#include +#endif +#endif + extern "C" { #ifdef _WIN32 // These are technically supposed to be defined linux/limits.h and @@ -34,7 +41,7 @@ int mkstemp(char* tn); char* realpath(const char* path, char* resolved_path); int setenv(const char* name, const char* value, int overwrite); int unsetenv(const char* name); -#else -extern char** environ; +#elif defined(__APPLE__) && (TARGET_OS_OSX || TARGET_OS_SIMULATOR) +#define environ (*_NSGetEnviron()) #endif } -- 2.34.1