From: Michael Lee Date: Sun, 29 Jan 2017 03:43:50 +0000 (-0800) Subject: char ** enivron is inconsistent on some platforms X-Git-Tag: v2017.03.06.00~71 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=0637780a1f6e49d4ec9026e24ba941bbd9991833;p=folly.git 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 --- 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 }