From d74b3b69053d29d491c3c1b1efef9ca7e7dcbe74 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 18 Sep 2009 05:00:14 +0000 Subject: [PATCH] NSGetEnviron --- direct/src/plugin/p3dSession.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/direct/src/plugin/p3dSession.cxx b/direct/src/plugin/p3dSession.cxx index c5cc121ba9..27f1ca1b6d 100644 --- a/direct/src/plugin/p3dSession.cxx +++ b/direct/src/plugin/p3dSession.cxx @@ -38,6 +38,10 @@ #include #endif +#ifdef __APPLE__ +#include +#endif + //////////////////////////////////////////////////////////////////// // Function: P3DSession::Constructor // Access: Public @@ -792,8 +796,12 @@ start_p3dpython(P3DInstance *inst) { // "environ" is a keyword. (!) extern char **_environ; char **global_environ = _environ; +#elif defined(__APPLE__) + // Apple doesn't guarantee that environ is available for shared + // libraries, but provides _NSGetEnviron(). + char **global_environ = *_NSGetEnviron(); #else - // Posix doesn't have an underscore. + // Posix is straightforward. extern char **environ; char **global_environ = environ; #endif // _WIN32